Skip to content
Ameen Abozaid
Planned lessonJNR-050-L02

Health checks and startup order

  • Lesson 2 of 5
  • Junior
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_on alone only waits for the container to start, not to be ready.
  • A healthcheck runs a command repeatedly to mark a service healthy.
  • depends_on: db: condition: service_healthy makes the app wait for a healthy database.
  • Postgres check: pg_isready. Tune interval, timeout, retries.
  • Apps should still retry connections; startup order is a convenience, not a guarantee.
Draft outline details

Demonstration

yaml
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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.