Containers: Docker, Compose and Swarm

Intermediate

Started doesn't mean ready

On almost every deployment the orders API crashes once: it connects before PostgreSQL accepts connections. depends_on is already in compose.yaml. Make every start of the stack succeed.

The API checks the database once at startup and exits if it can't connect. The test runs docker compose up -d, then 20 times docker compose down and up -d, and counts the starts where the API exited with an error.

What your server must hold

  • Every start of the stack succeeds
  • Availability ≥ 99 %

What you will master