Control Startup And Shutdown Order of Containers In Docker Compose

İbrahim Gündüz
Published in
2 min readMay 2, 2020


You may have an application that depends on one or more services that start slowly. So, you must put some extra controls before starting the application, in order to prevent startup errors and run the application smoothly.

Let’s take the following example:

We have an application that directly dependent on RabbitMQ and MySQL services and it connects to both services in application startup. However, the worker container constantly fails because it starts before the other services.

Let’s start first by defining the dependencies between the services in the docker-compose.yaml to start the worker container after RabbitMQ and MySQL containers.

As you see here, we just let docker-compose know worker service is dependent on both of mariadb