Have you watched this movie before, I did many times, but the most important idea is that Microsoft has changed a lot ..
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.
ENV DOCKERIZE_VERSION v0.2.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
entrypoint: dockerize -wait tcp://database:5432 kong start
tcp://database:5432with the service and the port that you are waiting for, lets say for example
tcp://nginxwhere we need to make sure that nginx is up and running on the default port 80.
kong startwith 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
Most of us run the node apps under the root user, so last time I talked about using IPTables to do some tricks which will route the requests from port 80 to port 8080.
Today I was able to do so without IPTables , and you can run this command with SUDO to give node the ability to use the port 80 :
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f `which node``
I used it on Ubuntu 16.04 and it worked like a charm.
PS: I noticed that the command was not clear so I need to put it in an image
PS: this is an experimental idea so it might not work for you.
I’ll try to make short here, so basically you will have to pass the IP with the expose port while you execute
docker run for example something like
docker run -p 10.0.0.10:5000:5000 -name container1 <someimage> <somecommand>
Now the question why do I need to do something like that since at the end docker will be bind to localhost and more specific to
0.0.0.0 , and to be honest this is just a simple try for me to imitate the ability to have two (or more) vagrant boxes running on the same machine and both has the port
80 exposed to the host.
So normally you will only have one image cause you cant have two images on the same port (or at least this is what I have in my mind right now), so the command above will help, now when you try it you will face a small problem, which is that the IP should be the same as your host IP and you cant have both images have the same IP, so it wont work and we have gain nothing, lets talk about how vagrant/virtualbox work, they do a small trick where virtualbox will create a virtual network adapter and configure it to have the IP which you specified in Vagrantfile, so I guess we will have to do the same Creating a new virtual network adapter.
Some how most of what we have talked about in the previous article about “How to configure PHPStorm to work with native Docker for mac“, so mostly you will have to do the same except that you dont need to install
socat but you will need to make sure that :
1- you have enabled the Disk Share on the drive that you are using like for example:
2- you will need to make sure that you are using the following address :
and everything else will be the same as the old post.
Happy Coding Everyone