The app starts before its database is ready
A Compose stack starts the app the moment the database container starts, not when it can accept connections, so the app crashes on boot. Make it wait for a healthy database.
Scenario
A two-service Compose stack: an app that talks to a db. The app keeps crashing on startup
because it connects before Postgres is accepting connections. The current depends_on only waits
for the database container to start, not to be ready.
Your job
In docker-compose.yml:
- Give the
dbservice a healthcheck that reports when Postgres is ready. - Make
appwait for the database to be healthy, not just started, using the long form ofdepends_onwithcondition: service_healthy.
What "done" looks like
db has a healthcheck, and app's depends_on names db with condition: service_healthy.
Graded on the Compose file's shape, not a live run.
Teaches: container start order:
depends_onalone only sequences container start; readiness needs a healthcheck plus aservice_healthycondition.
What gets checked
Your solution is verified against each of these:
- The database service defines a healthcheck
- The app declares a dependency on the database
- The app waits for the database to be healthy (depends_on condition service_healthy)
Solve it in your browser
No setup, no install. Write your solution in the editor and hit Check. The in-house engine renders and grades it instantly, then issues your proof the moment every check passes.
Solve in browser →Prefer your own lab?
- Build the fix locally. New to the tooling? See setting up your lab.
- Push your topology file, device configs, and any playbooks to a public repo (GitHub or GitLab).
- Submit the repo link. We review it by hand, confirm it works, and issue your proof page.