apple / apple/container

[Bug]: DNS not working

Open
#1,693 32 comments 3 reactions 1 assignee Claimed by @katiewasnothere View on GitHub
Dominant language
Swift
Stars
49.9k
Forks
1.8k
Avg merge
1d 20h
Merged PRs (30d)
22

Description

### I have done the following

- [x] I have searched the existing issues
- [ ] If possible, I've reproduced the issue using the 'main' branch of this project

### Steps to reproduce

Not applicable.

### Problem description

Hi folks,

I've been asked by @katiewasnothere to open a new issue for this, so here I am.
Since I'm using Apple Container (maybe 6 months), I never had the chance to get the DNS working. At best, it worked randomly not for long.
I'll paste it my previous messages.

- 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 "hotline.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.

## Following @jglogan questions, I've run the following test:

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.

As for `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.
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.

Last test was to delete / recreate the DNS without luck, as proposed here by @SeniorPlayer : https://github.com/apple/container/issues/856#issuecomment-4658844435
But he just answered that I might have to also create a new network, which I've not yet tested.

### Environment

```markdown
- OS: 26.5
- Xcode: 26.5
- Container: 0.12.3
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.