Run your docker images in order

One of the many things that I found annoying in Docker (when you use docker-compose) is that you have no control over the order which the images is going to be up and running, in the documentation they have pointed out to three ways, am not going to cover them all, am just going to cover my experience with dockerize and how I used it to make sure that the database is up and running before I run the next image.

PS: please note that my way is not the best way, but it worked for me, and you should invest more time knowing and familiarize yourself with dockerize.

  1. Make sure that you install dockerize within the image which should be waiting for other images to finish
  2. Make sure that your image does not have any service that run as daemon ( In my case it was NGINX )
  3. Make sure that your entrypoint should look like :
  4. You will need to replace  tcp://database:5432 with the service and the port that you are waiting for, lets say for example tcp://nginx where we need to make sure that nginx is up and running on the default port 80.
  5. You will need to replace kong start with the service that you want to run, in my case it was Kong server

You can look at this github repo where I created a small docker repo to run Kong and Postgresql out of the box

Filed under: docker, Linux, Nginx, Other

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *

Comment *

Name *
Email *
Website

20 − nineteen =