I have a dnsmasq service that is currently bound to 127.0.0.1 pointing to my minikube instance like so:
address=/.k8s.local/192.168.39.184
I'd like to run docker containers that will communicate with the minikube instance using the DNS I specified.
When I set the container's DNS using docker run --dns 127.0.0.1 ...
docker outputs the following message: WARNING: Localhost DNS setting (--dns=127.0.0.1) may fail in containers.
If I use the the host's network like so docker run --net host --dns 127.0.0.1 ...
everything works as expected.
How do I configure the docker bridge to also resolve DNS using my local dnsmasq service?
Best Answer
You can use the host's local DNS resolver (e.g.
dnsmasq
) from your Docker containers if they are on a user defined network. In that case a container's/etc/resolv.conf
will have the nameserver127.0.0.11
(a.k.a. the Docker's embedded DNS server), which can forward DNS requests to the host's loopback address properly.