Docker Compose Healthchecks: How to Make Services Wait for Postgres
A practical guide to Docker Compose healthchecks, depends_on service_healthy, start_interval, healthchecks without curl, and debugging unhealthy containers.
tags: docker, devops, tutorial, webdev
cover_image:
Docker Compose Healthchecks: How to Make Services Wait for Postgres, Redis and Your API
You run docker compose up, your API container starts, tries to connect to Postgres, and crashes with ECONNREFUSED or connection refused. You run it again and it works. You run it in CI and it fails one time out of five.
If that sounds familiar, the problem is not your code. It is the gap between a container being started and a service being ready.…