The classic startup race
Your API depends on Postgres. Compose starts both. The API container is up in 200ms. Postgres takes 4 seconds to be ready for connections. The API tries to connect, fails, exits. docker compose up reports the API died. The fix is not retry-loops — it's depends_on: condition: service_healthy.
service_healthy waits for HEALTHCHECK to pass
You add a HEALTHCHECK to the dependency (in the compose file or the Dockerfile). The dependent service waits until that check goes green before starting.