`docker compose up` says services are `unhealthy` and dependent services never start: `dependency failed to start: container db is unhealthy`.
IntermediateTroubleshootingResources, health checks, logging and restarts
Answer
Likely causes → Health check fails (wrong credentials, wrong command, slow initialization such as a DB restore).
Diagnose →
docker compose ps
docker compose logs db
docker inspect --format '{{json .State.Health}}' $(docker compose ps -q db) | jq
Fix → Correct the check (pg_isready -U $POSTGRES_USER), add start_period, fix env.
Prevent → Test health commands manually first.
More on Resources, health checks, logging and restarts
Container restarts repeatedly: `docker ps` shows `Restarting (1) 5 seconds ago`.Beginner`OOMKilled: true` and exit code 137.BeginnerContainer is `unhealthy` but the app works when tested manually.Intermediate`docker stats` shows 100%+ CPU and the container is slow.Intermediate`docker logs` is slow or `docker logs -f` hangs on a container with huge logs.Intermediate`Error response from daemon: configured logging driver does not support reading` when running `docker logs`.Intermediate