So we’ll configure Dnsmasq to listen to another available IP address, such as the one provided by docker0 interface, to solve this issue.Įdit the new file /etc/NetworkManager/dnsmasq.d/docker.
Docker can’t use it because it doesn’t allow to use a local DNS server if its IP address is a local configuration, such as 127.0.0.1. Ubuntu provides Dnsmasq, a local DNS server configured to use DNS server of your network through DHCP. This mapping allows pinging each container by. Use Names Not IP Addresses Static IP addressing for containers is an anti patter. So, that makes it kinda easy to get your current IP address for the docker exec command above.
DOCKER NETWORK DNS MANUAL
The link command can be used for manual DNS on the bridge network. Some irony here: You can locally lookup your local hosts IP address by a DNS lookup of, because Docker for Windows maintains that DNS name in your local C:WindowsSystem32driversetchosts file. DNS works differently for the default bridge network vs custom-defined networks. Docker then keeps a mapping of each name/hostname against the container’s IP address. DNS is used for communication between containers.
DOCKER NETWORK DNS HOW TO
You can find many, many documentation about how to configure Docker DNS on Ubuntu (such as official Docker doc), but none of them answer these requirements all together:ġ/ Configuration must be portable: works at home or at work or anywhere elseĢ/ Configuration must be written in files not provided by a deb package to avoid conflicts after package updates Portable configuration Container discovery on docker0 network (DNS resolution) Docker will assign a name and hostname to each container created on the default docker0 network, unless a different name/hostname is specified by the user. If you are in a corporate environment, resolution fails because you have to use your internal DNS server.