I have done the following
Steps to reproduce
- On the macOS host, configure and run a local DNS service like
dnsmasq.
- Crucially, configure this service to listen on port 53, but only on specific interfaces (e.g.,
lo0 at 127.0.0.1:53 and en0 at 192.168.24.39:53). It should not be listening on all interfaces (*:53).
- Start the
apple/container environment.
- Attempt to resolve an external domain from within a container.
- Alternatively, try to build an image that requires network access during the build process.
Current behavior
DNS resolution inside the container fails. The container's default DNS server, 192.168.64.1, is unreachable.
For instance, running nslookup inside a container results in a connection timeout:
$ container run --rm -i -t alpine:latest nslookup www.apple.com
nslookup: read: Connection refused
nslookup: read: Connection refused
;; connection timed out; no servers could be reached
Additional Context
$ ifconfig bridge103
bridge103: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
inet 192.168.64.1 netmask 0xffffff00 broadcast 192.168.64.255
...
- The Conflict: The root cause is a port binding conflict. My
dnsmasq service listens only on specific interfaces (e.g., 127.0.0.1:53).
- The Proof: The issue is resolved 100% of the time by stopping my
dnsmasq service. When it's off, apple/container successfully uses the host's mDNSResponder to bind *:53 and provide working DNS to containers.
- The Hypothesis: The container's DNS proxy (via
mDNSResponder) attempts a global bind to *:53. This fails if port 53 is already in use on any interface, preventing the DNS service for the container network gateway (192.168.64.1) from starting.
Expected behavior
- DNS resolution inside the container should work correctly using the default
192.168.64.1 resolver.
- The presence of another service on the host listening on
127.0.0.1:53 or 192.168.24.39:53 should not interfere with the container's DNS functionality.
Environment
- OS: macOS 15.6
- Xcode: Version 16.4 (16F6)
- Container: container CLI version 0.3.0 (build: release, commit: 3fcf647)
Relevant log output
Code of Conduct
I have done the following
Steps to reproduce
dnsmasq.lo0at127.0.0.1:53anden0at192.168.24.39:53). It should not be listening on all interfaces (*:53).apple/containerenvironment.Current behavior
DNS resolution inside the container fails. The container's default DNS server,
192.168.64.1, is unreachable.For instance, running
nslookupinside a container results in a connection timeout:Additional Context
dnsmasqservice listens only on specific interfaces (e.g.,127.0.0.1:53).dnsmasqservice. When it's off,apple/containersuccessfully uses the host'smDNSResponderto bind*:53and provide working DNS to containers.mDNSResponder) attempts a global bind to*:53. This fails if port 53 is already in use on any interface, preventing the DNS service for the container network gateway (192.168.64.1) from starting.Expected behavior
192.168.64.1resolver.127.0.0.1:53or192.168.24.39:53should not interfere with the container's DNS functionality.Environment
Relevant log output
Code of Conduct