Unable to ping Docker containers through hostnames / names

After upgrading to Docker engine 1.10 (from 1.08), I noticed that my reverse proxy configuration no longer works.

All my applications (including Nginx for reverse proxies) are containerized and linked via container names. Here is an example for some of the virtual hosts in Nginx:

server { server_name jobs; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://jenkins:8080; } } 

Now I can ping a Jenkins container from a Nginx container only through IP, but not through the container name. Since IP addresses are constantly changing due to updates, redistributions, etc., is there a better network way to avoid defining IP addresses in the reverse proxy configuration?

The legacy of --link not an option, as there are many containers.

+7
docker
source share
1 answer

You can check the network area alias that comes with docker network connect and docker run .

Running a container with an alias allows your NGinx to cancel the proxy for that alias in its configuration.
At run time, this alias will resolve the container that you started later.

See an example in Docker Networking: Automatically discover host names in a bridge network .
Please note that you will need a keystore to manage your container on the docker 1.10+ network.


Note (July 2016) with docker 1.12 and its swarm mode , it becomes even easier.
> See for example: Beautiful network stack in Docker Swarm mode

The docker road will determine the overlay network and keystore for you. The containers will see each other.

Another specific example: " NGINX as a reverse proxy for docker-rocker clusters "

+1
source share

All Articles