App container keeps crash-looping on startup because the database isn't ready yet
compose.yaml has app depends_on: [db], but the app's first DB connection attempt fails because Postgres is still initializing. Fix this properly. Expected reasoning: depends_on alone only sequences container start, not readiness; add a healthcheck to the db service (e.g., pg_isready) and change app's dependency to depends_on: db: condition: service_healthy so Compose waits for Postgres to report healthy before starting the app. As a defense in depth, the app itself should also have connection retry logic, since this guarantee is Compose-specific and won't hold in environments without Compose's
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.
App container keeps crash-looping on startup because the database isn't ready yet