[23.0 backport] libnetwork: check DNS loopback with user DNS opts #45000
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.
--dns-opt
breaks resolving of external names by internal DNS server docker/for-linux#1404systemd-resolved
#43705- What I did
DNS servers in the loopback address range should always be resolved in the host network namespace when the servers are configured by reading from the host's /etc/resolv.conf. The daemon mistakenly conflated the presence of DNS options (
docker run --dns-opt
) with user-supplied DNS servers, treating the list of servers loaded from the host as a user- supplied list and attempting to resolve in the container's network namespace. Correct this oversight so that loopback DNS servers are only resolved in the container's network namespace when the user provides the DNS server list, irrespective of other DNS configuration.- How I did it
Should be self-explanatory.
- How to verify it
Run a daemon on a host with DNS resolved by systemd-resolved or some other configuration with loopback-to-localhost DNS resolution. Run a container attached to a user-defined network with some
--dns-opt
flag and verify that DNS resolves within the container.- Description for the changelog
--dns-opt
or--dns-search
flags and systemd-resolved is used for DNS resolution on the host.- A picture of a cute animal (not mandatory but encouraged)