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 in Docker by Namik
• 1,210 points
148 views

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 by Sirajul
• 40,990 points

edited Jul 3 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,160 points

edited Oct 16, 2018 by lina 5,842 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 6 in Docker by Kunal
2,279 views
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
• 46,040 points
62 views
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 27, 2018 in Docker by Kalgi
• 46,040 points
58 views
0 votes
1 answer
0 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
• 57,300 points
265 views
0 votes
1 answer
0 votes
2 answers