Interview Prep/Docker/Resources, health checks, logging and restarts

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

All Docker questions Roadmap: Docker & containers

More on Resources, health checks, logging and restarts