Why Docker compose does not wait for a container to be ready before moving on to start next service in dependency order

0 votes
Jul 2, 2019 in Docker by Namik
• 1,230 points

1 answer to this question.

0 votes

Docker Compose always starts and stops containers in dependency order, where dependencies are determined by depends_on, linksvolumes_from, and network_mode: "service:...".

However, for startup Docker Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running. There’s a good reason for this:

  • The problem of waiting for a database (for example) to be ready is really just a subset of a much larger problem of distributed systems. In production, your database could become unavailable or move hosts at any time. Your application needs to be resilient to these types of failures.
  • To handle this, design your application to attempt to re-establish a connection to the database after a failure. If the application retries the connection, it can eventually connect to the database.
  • The best solution is to perform this check in your application code, both at startup and whenever a connection is lost for any reason.
answered Jul 2, 2019 by Sirajul
• 59,230 points

edited Jul 3, 2019 by Sirajul

Related Questions In Docker

+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 33,538 views
+1 vote
4 answers

Docker Compose wait for container X before starting Y

You can use the depends_on feature was ...READ MORE

answered May 7, 2019 in Docker by Kunal
0 votes
1 answer

Is it possible to start a shell session in a running container (without ssh)

use this docker exec -it "id of running ...READ MORE

answered Jul 25, 2018 in Docker by Kalgi
• 52,360 points
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
0 votes
1 answer

Why do I get Connection reset by peer when making a request to a service running in a container?

Typically, this message is returned if the ...READ MORE

answered Jul 10, 2019 in Docker by Sirajul
• 59,230 points
0 votes
2 answers
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP