This is a simple container written to resolve containers IPs and be just like any other DNS resolver (but locally).
It will simply try to to map all the running containers to their IP addresses (including himself)
I was tired of always needing to find the IP address of the gazillion containers I manage.
Updating the /etc/hosts
file was not an option for me, as I want that mapping on my phone too, and I access them using VPN (thanks pritunl).
This is just a personal tool, this was never tested for production
git clone https://github.com/nimda95/docker-dns.git
docker build -t \<local-name-for-this-image-build\> .
Pull from docker hub
docker pull shimgapi/docker-dns
docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name docker-dns docker-dns
docker logs -f docker-dns #just to get the usable IPs to be used
Choose from from the IPs that are displayed in the logs and add the suitable one for your setup to your /etc/resolv.conf
as follows nameserver 172.16.0.1
(I put it on top of the other nameservers)
You can customize this image to your environment by changing these env variables
Name | Description | Default Value |
---|---|---|
AUTO_REFRESH_INTERVAL |
Time in milliseconds to refresh the list of running containers | 5000 |
DNS_LISTEN_PORT |
Port for the DNS to listen on | 53 |
REMOTE_RESOLVER_ADDR |
resolver address to be used to lookup internet addresses | 1.1.1.1 |
REMOTE_RESOLVER_PORT |
resolver port to be used to lookup internet addresses | 53 |
LIMIT_NETWORKS |
networks to include ips from in the lookup separated by comma (default=all) | `` |
PRs are welcome.