advancedTop 100 Interview Questions

Why doesn't `depends_on` alone guarantee a dependency is ready to accept connections?

By default, `depends_on` only waits for the dependency's container to start, not for the application inside it to finish initializing (e.g., a database accepting connections). Use `depends_on: condition: service_healthy` paired with a proper HEALTHCHECK to actually wait for readiness.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why can't you combine a fixed host port mapping with `docker compose up --scale`?← Back to all Docker questions