Skip to content

Bind the resolver directory so DNS works in the sandbox - #15

Merged
didvc merged 1 commit into
masterfrom
fix-resolv
Oct 20, 2026
Merged

didvc merged 1 commit into
masterfrom
fix-resolv

Conversation

@didvc

@didvc didvc commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Closes #1.

Sharing the network namespace is not enough to resolve names. /etc is bound read-only, but on systemd-resolved and NetworkManager systems /etc/resolv.conf is a symlink into /run, and the sandbox replaces /run with an empty tmpfs. The symlink dangles and the agent sees no nameserver, so it looks like the sandbox has no network rather than no DNS.

Reported on Ubuntu 24.04, independently hit on Fedora. Both reporters used the same manual bind.

The fix follows the symlink and binds the directory it points at, read-only, when networking is shared. That works for any resolver that symlinks out of /etc. A plain file in /etc needs nothing extra, and --no-net adds nothing.

This machine has a regular /etc/resolv.conf, so I verified against a simulated systemd-resolved host. Before, the agent got "cat: /etc/resolv.conf: No such file or directory". After, it reads the nameserver.

Tests cover the mount argument and the behaviour. Both fail without the wrapper change. The argv tests skip where /etc/resolv.conf does not symlink outside /etc; CI runs Ubuntu, so they fire there.

Closes #1.

Sharing the network namespace is not enough to resolve names. /etc is
bound read-only, but on systemd-resolved and NetworkManager systems
/etc/resolv.conf is a symlink into /run, and the sandbox replaces /run
with an empty tmpfs. The symlink dangles, the agent sees no nameserver at
all, and the symptom reads as "the sandbox has no network" rather than
anything to do with DNS. Reported on Ubuntu 24.04 and independently hit
on Fedora; both reporters worked around it with the same manual bind.

Follow the symlink and bind the directory it points at, read-only, when
networking is shared. Following the link rather than hardcoding a path
keeps this working across resolver implementations, and a plain file in
/etc needs nothing extra because /etc is already bound. --no-net adds
nothing, since there is no resolver to reach.

Verified against a simulated systemd-resolved host: before, the agent got
"cat: /etc/resolv.conf: No such file or directory"; after, it reads the
nameserver. Tests cover both the mount argument and the behaviour, and
both fail without the fix.
@didvc
didvc merged commit 88007c6 into master Oct 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ubuntu 24.04: no network by default

1 participant