How to Debug a service unhealthy Error in CI
An unhealthy error means the healthcheck probe kept failing, so read the probe output and confirm the service really accepts connections.
When CI prints dependency failed to start: container <svc> is unhealthy, inspect the healthcheck with docker inspect to see the last probe output, then fix the probe or extend start_period.
Steps
- Print the last probe output with
docker inspect. - Confirm the probe command works inside the container.
- Increase
start_periodfor slow boots, or fix the probe target.
Inspect the probe
Terminal
docker inspect --format '{{json .State.Health}}' \
$(docker compose ps -q db) | jq .
docker compose exec db pg_isready -U postgresGotchas
- A probe that checks the wrong port or host reports unhealthy even when the service is fine.
- Alpine images may lack the tool your probe calls; install it or use
CMD-SHELLwith a built-in.
Related guides
How to Add Compose Healthchecks and Gate CI on ThemDefine healthcheck blocks in docker-compose.yml with test, interval, and retries so docker compose up --wait…
How to Dump Compose Logs on Failure in CICapture docker compose logs when a CI job fails so you can see why a service crashed or never became healthy,…
How to Run docker compose up and Wait for Healthy Services in CIStart a Compose stack in CI with docker compose up -d and block until every service is healthy using the --wa…