[Bug]: internal DNS does not work (clean install)
I have done the following
- [x] I have searched the existing issues
- [x] If possible, I've reproduced the issue using the 'main' branch of this project
Steps to reproduce
Last week I had a setup where internal DNS worked pretty well. I wiped my device and did a clean reinstallation of container 0.6.0 (and also tested a debug build on the latest github code)
I run :
container run -d --rm --name web nginx
container run -it --rm alpine sh
/ # ping web
ping: bad address 'web'
/ # ping -4 web
ping: bad address 'web'
/ # nslookup web
Server: 192.168.2.1
Address: 192.168.2.1:53
** server can't find web: NXDOMAIN
** server can't find web: NXDOMAIN
/ # nslookup google.com
Server: 192.168.2.1
Address: 192.168.2.1:53
Non-authoritative answer:
Name: google.com
Address: 142.250.64.174
Non-authoritative answer:
Name: google.com
Address: 2607:f8b0:4008:815::200e
Current behavior
container name resolution does not work at all
Expected behavior
container names should resolve correctly
Environment
- OS: macOS 26.0.1
- Xcode: latest
- Container: Container CLI 0.6.0 (and latest from `main`)
Maybe I'm doing something wrong, but I expect this to work actually because it did. Please let me know if you need more information from my system
Relevant log output
N/A
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Could be alpine related, can you try debian? I have run into this before: https://github.com/apple/container/issues/480
Yes I also tried debian , same behavior unfortunately. I am looking for a way to debug this further as it remains a mystery why this was working properly last week and as this is such a basic scenario, I must be doing something wrong on my machine
sudo container system dns create mycorp
container system property set dns.domain mycorp
After a couple of hours trial and error today the lines above is what makes it work. I must have had that done during my initial testing (before wiping the device). Not sure it's in the docs yet but it definately should be in there as users might expect inter-container dns working out of the box
I ran into the same thing. Setting those properties got the containers talking to each other, but I later had to remove them when building images. With the custom DNS domain set, connections from inside the containers couldn’t reach the outside world.
Clearing those settings fixed it for me:
container system property clear dns.domain
sudo container system dns rm mycorp
container system stop && container system start
For now, it looks like I need to toggle these settings depending on whether I’m building images or running containers.
This is bizarre to read, because at my employer I'm trying to do apt update from within an ubuntu container and the container can't resolve anything no matter what I do, and it doesn't matter if I'm building a container or running one. other tools which use MacOS Linux VMs (outside of container entirely) can use DNS just fine. it's like the host OS is blocking DNS resolution for things running inside container and nothing else, and I don't understand how that can happen. running version 0.7.0.
@naikrovek Could you provide the output of sudo lsof -i 53?
user@hostname ~> sudo lsof -i :53
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ZscalerTu 575 root 16u IPv4 0x1a4d63f6bd75d6ef 0t0 UDP 100.64.0.1:domain
ZscalerTu 575 root 36u IPv6 0x3dee9d9719d8ccd8 0t0 UDP [fc00::6440:1]:domain
user@hostname ~>
That answers it for me. Zscaler is bound to that port.
I was running this command because I found #402 and read through it and sure enough, something is using port 53.
Zscaler is ... the worst. It breaks everything.
For those that don't know, Zscaler is a MITM cloud proxy which intercepts every HTTPS request, decrypts it, logs the requests, re-encrypts and passes it on to the server you were trying to reach as an HTTP client. it rewrites requests and responses according to rules and basically usurps TLS and makes the entire TLS superstructure of the web pointless.
@jglogan I answered above if you didn't already see. I can work around Zscaler with the --dns parameter for container run but that doesn't help one container resolve another. fortunately, I almost never need to do this.
Hi folks,
Is my issue related?
- I've set up a DNS (tested twice both with Orchard GUI and command line)
- DNS is "cont"
- "cont" is set as default DNS
- container have been stop && start
- All my containers have now DNS like "nginx.cont"
Issue: ping containerName.cont from the host sometimes works, most of the time not.
ping hotline.cont
ping: cannot resolve hotline.cont: Unknown host
I've tried:
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder; sleep 2;
--> This does not necessarily help. Doing so could make some containers to answer ping while other are still not.
@naikrovek Exactly. See also #345 and #817.
Zscaler, dnsmasq, or anything else listening on port 53 creates a situation where the macOS DNS service can't start its listener on that port. Unfortunately, this behavior isn't something we have control over.
I've created apple/containerization#436 for one possible workaround for this issue. Should we do that we can then create an issue here to plumb the feature up into container run.
@Tazintosh Do you see the cont domain in the output of scutil --dns?
e.g.
resolver #11
domain : test
search domain[0] : test
nameserver[0] : 127.0.0.1
port : 2053
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
You should also see a configuration file on your system for the local domain:
% cat /etc/resolver/containerization.test
domain test
search test
nameserver 127.0.0.1
port 2053
Also, check the output of sudo lsof -i :53.
Hi @jglogan I'm seeing this under "DNS Configuration" (not under "DNS configuration (for scoped queries)"
resolver #8
domain : cont
search domain[0] : cont
nameserver[0] : 127.0.0.1
port : 2053
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
Then:
someuser@server / % cat /etc/resolver/containerization.cont
domain cont
search cont
nameserver 127.0.0.1
port 2053%
Finally:
sudo lsof -i :53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mDNSRespo 229 _mdnsresponder 43u IPv4 0x5f33a6a3de94a4df 0t0 UDP *:domain
mDNSRespo 229 _mdnsresponder 49u IPv6 0x616fc247567ec376 0t0 UDP *:domain
mDNSRespo 229 _mdnsresponder 50u IPv4 0x1c0e209ca670818d 0t0 TCP *:domain (LISTEN)
mDNSRespo 229 _mdnsresponder 72u IPv6 0x1c3461e474ed7309 0t0 TCP *:domain (LISTEN)
Ping still not resolving.
How about sudo lsof -i :2053
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
container 37587 someuser 12u IPv4 0x5073de1ed066b2f1 0t0 UDP localhost:lot105-ds-upd
All my container's DNS seems to resolve at the moment… It's good but I've no idea why. BTW, when I ping each of them one after each other, one did not resolve at first, and when I tried a second time after about a minute, it did… Anyway, I've the feeling the next time I'll start a container, all of this won't work anymore.
[Edit] I was right (kind of). Less than 10s after successfully testing again pinging my DNS after this post, nothing was resolving anymore. But contrary to my feeling, it was even without a single action from me in between BTW.
After a couple of weeks of testing, the DNS behaviour is flaky at best. After a reboot and starting all containers everything works but after "some" time thing just start to break down. Internal DNS resolving from within the containers no longer work.
scutil :
resolver #8
domain : eva
search domain[0] : eva
nameserver[0] : 127.0.0.1
port : 2053
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)`
lsof -i :53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mDNSRespo 184 _mdnsresponder 20u IPv4 0x35e752c7b6a56472 0t0 UDP *:domain
mDNSRespo 184 _mdnsresponder 21u IPv6 0x91983a720e3b082a 0t0 UDP *:domain
mDNSRespo 184 _mdnsresponder 22u IPv4 0xe2b62073f159a240 0t0 TCP *:domain (LISTEN)
mDNSRespo 184 _mdnsresponder 23u IPv6 0x350a10b46199942d 0t0 TCP *:domain (LISTEN)
sudo lsof -i :2053
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
container 528 root 14u IPv4 0x56db5926a6f26806 0t0 UDP localhost:lot105-ds-upd
@jglogan any ideas on what I can do to pinpoint the cause of this?
I'm having a similar issue when building an image. No 3rd party DNS services involved. Before container system start, no one is listening on port 53.
container system status
apiserver is not running and not registered with launchd
sudo lsof -i :53
<nothing>
Starting the container.
container system start
Verifying apiserver is running...
container system status
apiserver is running
application data root: /Users/.../Library/Application Support/com.apple.container/
application install root: /usr/local/
container-apiserver version: container-apiserver version 0.7.1 (build: release, commit: 420be74)
container-apiserver commit: 420be748f18afc685d11987ac5118c928e174c19
sudo lsof -i :53
<still nothing>
ifconfig | grep bridge100
<nothing>
Now starting the build. The Dockerfile has the following lines in it:
FROM internal-FQDN/os/oraclelinux:9-slim as swift-build
COPY --from=another-internal-FQDN/path:1.50 / /
container build --arch amd64 -t test .
=> [resolver] fetching image...
=> [resolver] fetching image...
=> [internal] load .dockerignore => => transferring context: 2B => [internal] load build context => => transferring context: 1.38GB => CACHED .....
=> => resolve internal-FQDN/os/oraclelinux:9-slim@sha256:...
=> ERROR FROM another-internal-FQDN/path
=> => resolve another-internal-FQDN
------
> FROM another-internal-FQDN
------
Error: unknown (2): failed to solve: failed to load cache key: failed to do request: Head "https://another-internal-FQDN/path": dial tcp: lookup another-internal-FQDN on 192.168.64.1:53: read udp 192.168.64.2:49171->192.168.64.1:53: i/o timeout
sudo lsof -i :53
<now something starts showing up>
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mDNSRespo 690 _mdnsresponder 65u IPv4 0xa0333592b0e0ef03 0t0 UDP *:domain
mDNSRespo 690 _mdnsresponder 70u IPv6 0xe5346de6a26dfbe9 0t0 UDP *:domain
mDNSRespo 690 _mdnsresponder 77u IPv4 0xed210cd717006116 0t0 TCP *:domain (LISTEN)
mDNSRespo 690 _mdnsresponder 78u IPv6 0x19ee3aab42d389dc 0t0 TCP *:domain (LISTEN)
ifconfig | grep bridge100 -A 3
<this is new after the build attempt>
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 82:a9:97:d0:2b:64
inet 192.168.64.1 netmask 0xffffff00 broadcast 192.168.64.255
If I just do `container image pull another-internal-FQDN/path', it downloads the image just fine. But when I try to build it again, it doesn't see to use the cached image and fails on the resolver.
Podman and docker work fine.
@naikrovek Exactly. See also #345 and #817.
Zscaler,
dnsmasq, or anything else listening on port 53 creates a situation where the macOS DNS service can't start its listener on that port. Unfortunately, this behavior isn't something we have control over.I've created apple/containerization#436 for one possible workaround for this issue. Should we do that we can then create an issue here to plumb the feature up into
container run.
I'm running into this with Container, but it hasn't been an issue with Podman, Docker Desktop, or Finch. How do the others do it? Binding to a different localhost address (e.g. 127.0.0.11) may be the way.
Hi, I've just updated from 0.7.1 to 0.11.0 and I still cannot ping my containers using their DNS. Even from the host computer.
ping Hotline.cont
ping: cannot resolve hotline.cont: Unknown host
Hi folks, Running 0.12.3 and DNS is still not working. Any news @jglogan?
This...was...working? And now...is not?