depends_on alone makes Compose start a service after its dependency's container has started, not after it is ready to accept connections. Without a healthcheck on the dependency, Compose has no way to know when it is ready. The explainer flags, as low, any service that others depend on but that has no healthcheck. Add one and use condition: service_healthy.
openrouting — compose explainer
$ explain docker-compose.yml! cache has no healthcheck lowline 9fix: see below$
What the free Docker Compose explainer reports on the risky example below.
Why it matters
A database container counts as started as soon as its process launches, often seconds before it accepts connections. Dependents that connect right away fail, and depending on the restart policy they crash-loop or stay down.
Teams often work around this with sleeps or retry scripts in the entrypoint, which hide the problem rather than describe it.
A healthcheck also gives `docker compose ps` and monitoring a real readiness signal, not just whether the process exists.
Add a healthcheck to the dependency with a command that succeeds only when it is ready, such as pg_isready for Postgres or redis-cli ping for Redis.
Switch the dependent's depends_on to the long form with condition: service_healthy.
Keep connection retries in the application too: a healthcheck covers start-up, not a dependency that restarts later.
When it's acceptable
Dependencies that are ready the moment their process starts, or dependents that already retry their connections gracefully.
Check your own docker-compose.yml
The risky example is loaded below. Paste your own file to check it for this and every other Docker Compose rule. It runs in your browser; nothing is uploaded.