I have a dnsmasq service that is currently bound to pointing to my minikube instance like so:


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 ... docker outputs the following message: WARNING: Localhost DNS setting (--dns= may fail in containers.
If I use the the host's network like so docker run --net host --dns ... everything works as expected.
How do I configure the docker bridge to also resolve DNS using my local dnsmasq service?


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 nameserver (a.k.a. the Docker's embedded DNS server), which can forward DNS requests to the host's loopback address properly.

$ cat /etc/resolv.conf
$ docker run --rm alpine cat /etc/resolv.conf
$ docker network create demo
$ docker run --rm --net demo alpine cat /etc/resolv.conf
options ndots:0    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.