Menu

Docker Compose Healthcheck and depends_on Explained
📰

Docker Compose Healthcheck and depends_on Explained

DEV Community: docker·devTalk·9 days ago
#jkEgtAug
#devtodocker#devto#dev#compose#docker
Long article (2513 words) — no AI summary yet.
Reading 0:00
15s threshold

Last updated: 18 November 2026. Tested with Docker Engine 29.9.2 and Docker Compose v5.7.0. See How this was checked at the end for what was and was not run.

The classic Compose failure: docker compose up starts MySQL and your Laravel container at the same moment, the app runs php artisan migrate while MySQL is still initializing, and you get Connection refused . You added depends_on: [db] , so it should have waited. It did wait, for the container to start . Docker's own documentation is explicit: on startup, Compose does not wait until a container is "ready", only until it is running.

The fix is a healthcheck on the dependency plus condition: service_healthy on the dependent. That is a few lines, but the details decide whether it works: the default timings, what happens during startup, how your check command behaves when the service half-works, and what a broken check looks like.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.