Health checks and startup order
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
make services start in a usable order.
Planned topics
depends_onalone only waits for the container to start, not to be ready.- A
healthcheckruns a command repeatedly to mark a service healthy. depends_on: db: condition: service_healthymakes the app wait for a healthy database.- Postgres check:
pg_isready. Tuneinterval,timeout,retries. - Apps should still retry connections; startup order is a convenience, not a guarantee.
Draft outline details
Demonstration
db:
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
retries: 10
app:
depends_on:
db: { condition: service_healthy }Check your understanding
Why is plain depends_on not enough?
Show answer
It does not wait until the database accepts connections.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.