Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.0 backport] libnetwork: check DNS loopback with user DNS opts #45000

Merged
merged 1 commit into from Feb 14, 2023

Conversation

corhere
Copy link
Contributor

@corhere corhere commented Feb 14, 2023

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

$ docker network create br1
006efd576eab62b9503e3d0a8ea642836a01c052c83531e955dd25b7e29fd470
$ docker run --rm --network br1 --dns-opt attempts:1 alpine nslookup google.com
Server:		127.0.0.11
Address:	127.0.0.11:53

Non-authoritative answer:
Name:	google.com
Address: 142.251.41.78

Non-authoritative answer:
Name:	google.com
Address: 2607:f8b0:400b:804::200e

- Description for the changelog

  • Fixed an issue which would cause DNS resolution to fail inside containers attached to user-defined networks when the container is created using the --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)

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.

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit 046cc9e)
Signed-off-by: Cory Snider <csnider@mirantis.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@corhere corhere merged commit 111658c into moby:23.0 Feb 14, 2023
@corhere corhere deleted the backport-23.0/fix-dns-opt-host-loopback branch February 14, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants