fix: allow localhost DNS servers when using host network#4653
Merged
AkihiroSuda merged 1 commit intocontainerd:mainfrom Jan 9, 2026
Merged
fix: allow localhost DNS servers when using host network#4653AkihiroSuda merged 1 commit intocontainerd:mainfrom
AkihiroSuda merged 1 commit intocontainerd:mainfrom
Conversation
df19f68 to
71836a8
Compare
AkihiroSuda
reviewed
Dec 15, 2025
AkihiroSuda
reviewed
Dec 15, 2025
Member
There was a problem hiding this comment.
Can we have some integration tests too?
nerdctl/cmd/nerdctl/container/container_run_network_linux_test.go
Lines 935 to 978 in 20a3eeb
Contributor
Author
There was a problem hiding this comment.
I have implemented some simple integration tests. I don't think we should modify host /etc/resolv.conf content on-the-fly.
Contributor
Author
There was a problem hiding this comment.
I'm investigating CI failure in rootless setup.
Contributor
Author
There was a problem hiding this comment.
Previous CI failure due to:
- Some rootless CI job make use of slirp, which provides a different DNS server than the host. The test case is modified to handle this.
pkg/resolvconfhas special handling to retrieve the real DNS servers behind systemd-resolved when it sees 127.0.0.53 (systemd-resolved stub). When using host network, this special handling is unwanted. IMHO, this special handling is problematic. systemd-resolved can freely choose DNS servers from other links when netif comes and goes. We really should not stick on the "current" state of which DNS servers are choosen by systemd-resolved.
9c02946 to
5414499
Compare
This commit addresses the issue where nerdctl was unconditionally stripping localhost DNS servers from /etc/resolv.conf when container is using host network. Fixes: #4651 Signed-off-by: Youfu Zhang <zhangyoufu@gmail.com>
Member
|
Let's wait for @AkihiroSuda's review to see if he has any comments on the latest changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(This change is vibed by Claude Haiku 4.5, reviewed by human.)
This commit addresses the issue where nerdctl was unconditionally stripping localhost DNS servers from /etc/resolv.conf when containers used --network=host.
Changes made:
resolvconf.FilterResolvDNSWithLocalhostOption(), likeresolvconf.FilterResolvDNS()but allows controlling whether localhost nameservers are preserved.The fix ensures:
Fixes: #4651