Back to questionsWhat does
JuniorTheoryVery common
What does depends_on: [db] guarantee when docker compose up starts api?
services:
api:
image: shop/api:2.4.1
depends_on: [db]
db:
image: postgres:17
environment: { POSTGRES_PASSWORD: secret }Only the order: Compose starts the db container before api. It does not wait for Postgres to accept connections, so the first connect from api can fail; that needs a healthcheck and service_healthy.
- Expecting
depends_onto wait until the database accepts connections - Leaving out retries in the app because Compose seems to start the database first
- How do you write a
healthcheckfor Postgres incompose.yaml? - Which
depends_oncondition waits for a one-off migration container to finish?