← All challenges
easydevops~25 min

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 db service a healthcheck that reports when Postgres is ready.
  • Make app wait for the database to be healthy, not just started, using the long form of depends_on with condition: 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_on alone only sequences container start; readiness needs a healthcheck plus a service_healthy condition.

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?

  1. Build the fix locally. New to the tooling? See setting up your lab.
  2. Push your topology file, device configs, and any playbooks to a public repo (GitHub or GitLab).
  3. Submit the repo link. We review it by hand, confirm it works, and issue your proof page.
Submit your solution →