depends_on

A Compose setting that makes one service start only after the services it needs.

In more detail

By default depends_on only waits for the other container to start, not to be ready. Add condition: service_healthy with a health check on the database so the API waits until the database actually accepts connections. Your application should still retry, because dependencies can restart later.

Example

depends_on:
  db:
    condition: service_healthy

Related terms

Taught in

References