Docker Compose depends_on does not wait for database readiness, causing flaky tests
A developer discovered that Docker Compose's depends_on directive in its short form only waits for a container to start, not for the service within it to become ready. This caused 11 out of 50 test runs to fail because the application attempted to connect to Postgres before it was accepting connections. The failure rate of 22% was especially problematic in fresh CI environments where database initialization takes longer. The article explains that the correct solution is to use the long form of depends_on with a healthcheck condition and to configure a specific TCP-based healthcheck command for Postgres.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in