The myth about Docker depends_on and links
Published 4 years and 6 months ago, Categorized under: Code, docker, Linux, MySQL, Nginx, PHP

I have been reading lately (again) a lot of articles which try to explain to the developers how to use Docker for development, now they are all good (in general), each try to make simple and easy for you to move and use docker, and everyone advice you to use depends_on and links (but remember links is a legacy compose item so with Docker 1.13 you should use depends_on ).

both some how works the same, except that depends_on will give you the ability to define the order which your images should start.

so if we have the following images :

  • php
  • nginx
  • mysql
  • redis

using depends_on you can tell PHP to start after mySQL and Redis not before them.

This is really really nice, but its not enough.

as noted in the documentation( :

Note: depends_on will not wait for mysql and redis to be “ready” before starting php - only until they have been started. If you need to wait for a service to be ready, see Controlling startup order for more on this problem and strategies for solving it.

So I guess now you got the point, you can control the order of the starting process, but you cant be sure if the service is ready or not, I'll tell you how I do that but this is a topic for another post.

Share It via: