Docker Community Forums

Share and learn in the Docker community.

Windows docker desktop - dnsmasq container started in Ubuntu - udp port 53 not accessible outside shell

I am creating a development environment and need a way to have other devices on the local network resolve a hostname: to the specific IP address of the docker host. The other devices are a combination of mobile phones, etc. and it’s not possible to just add a entry to their hosts file (at least on iPhones).

So, I decided to use a dnsmasq container that would be configured to return the correct IP address.

The idea being that I would point the mobile devices to use the windows IP address as their DNS servers.

However, on Windows if I run the dnsmasq container inside of a windows bash shell (Ubuntu), UDP port 53 is not bound to the UDP port 53 on the host. I can run nslookup and set the server to localhost inside the shell and the DNS resolution works correctly, but trying to use the IP address of the windows machine does not work.

But, if I run the dnsmasq container inside of a windows cmd shell, it does work. I can run dig @IP_OF_WINDOWS_MACHINE hostname, and I get back the dnsmasq configured IP address.

Other daemons work as expected, e.g. running a webserver in a container started in the bash shell that maps port 80 in the container to port 10000 is accessible via localhost. But it’s not accessible using the windows machine’s ip address.

Can someone explain why the behaviour is different depending on where I execute the docker run command?