Change DNS value of a container build with docker-compose in a Docker Swarm environment

508 views Asked by At

Greetings to all in this beautiful beginning of year 2017

I have a "micro-service" application build with docker-compose and orchestrating by docker Swarm on an Azure Container Service Cloud. The version of Docker on Azure is 1.12.5.

I’ve set up a site-to-site VPN to allow some applications to connect herself with some servers hosted in our place. VPN connection work like a charm. I can ping the private DNS and other servers from a virtual machine in Azure Cloud. What is annoying, is that docker-compose did not take care of the definition of an other DNS Server. In my docker compose, I’ve defined the IP of our private DNS and the two IP of Google public DNS :

version: '2'
services:
   myApp:
      build: something
      dns:
         - X.X.X.X
         - 8.8.8.8
         - 8.8.4.4

As you doubt, this does not work. The /etc/resolv.conf of myApp does not contain these IPs.

I’ve try to run myApp with this kind of command:

docker run myAppContainer –dns X.X.X.X …

And by this way the myApp container use, as I want, our private DNS.

I saw a lot of post who give a simple solution by editing docker’s default value on the host(/etc/default/docker). But with the setup I have in Azure, I’can’t change anything in the virtual machines who host the Swarm agent.

So, I really need your help.

1

There are 1 answers

1
Waldo On

When we create an Azure Container Service, Azure create a Swarm Master virtual Machine with a Subnet and a Swarm Agent (with some VMs) and its own Subnet.

So we have two subnet and if I want to defined a DNS hosted behind a VPN, the Swarm Master and Swarm Agent must be able to use the VPN. Docker can't resolve hosts name if only one can use the VPN.

My problem was that only the Swarm Agent had access to the VPN...