One compose file that knows what’s going on, not five Dockerfiles guessing
For local dev, docker-compose.yml should be the source of truth for how services talk to each other — ports, env vars, dependency order via depends_on with healthchecks, not condition: service_started alone (which doesn’t wait for the service to actually be ready).
services:
db:
image: postgres:16
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
retries: 10
api:
build: .
depends_on:
db:
condition: service_healthy
[!CHECKPOINT] Verify the dependency order Run
docker compose upand confirmapidoesn’t start untilpg_isreadyreports success — check the logs for the healthcheck retries, not just that both containers eventually show as running.