It’s possible solve containers by their container or service name, consider the following sample,
the container my-nginx
can be solved by querying the hostname my-nginx.docker
, the .docker
domain is also
configurable by the domain
configuration json property.
$ docker run --rm --name my-nginx nginx
$ nslookup my-nginx.docker
Server: 172.17.0.3
Address: 172.17.0.3#53
Non-authoritative answer:
Name: my-nginx.docker
Address: 10.0.2.3
You can enable this feature by
Activating by command line
./dns-proxy-server -register-container-names
Configuring at json config file
...
"registerContainerNames": true
...
Using environment variable
MG_REGISTER_CONTAINER_NAMES=1 ./dns-proxy-server
You can also customize the domain from docker to whatever you want by
Activating by command line
./dns-proxy-server --domain docker
Configuring at json config file
...
"domain": "docker"
...
Using environment variable
MG_DOMAIN=docker ./dns-proxy-server