Skip to content

Erroneously filtering out non-local IPv6 DNS servers when using user-defined networks #46968

@maleadt

Description

@maleadt

Description

I'm having an issue with docker and IPv6 nameservers when using user-defined networks. As is well-known, when using both IPv4 and IPv6 nameservers, musl-based containers can have issues looking up hostnames due to a race looking up hostnames using both nameservers and using the first response. This manifests on my set-up where I'm trying to resolve a local domain name, which fails when done using the default Google DNS servers as set-up by docker.

The documentation states that Google DNS servers are only used with user-defined networks when the host's resolve.conf does not provide any non-local nameservers. My resolve.conf does, however, and I think that docker is erroneously filtering out my IPv6 nameserver:

❯ resolvectl | cat
Global
       Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (enp89s0)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.0.2
       DNS Servers: 192.168.0.2 fe80::ba27:ebff:fe58:5993

Note how I'm using systemd-resolved, however, that doesn't seem to be an issue for Docker when using the default network:

❯ docker run debian cat /etc/resolv.conf
nameserver 192.168.0.2
nameserver fe80::ba27:ebff:fe58:5993%2

When using docker with a user-define network, however, things go wrong and my fe80 nameserver is replaced by Google DNS servers:

❯ docker run --network web debian cat /etc/resolv.conf
nameserver 127.0.0.11
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
options edns0 trust-ad ndots:0

Because of the Google DNS servers there, resolving *.localdomain hostnames often fails on musl.

Reproduce

Included in description.

Expected behavior

No response

docker version

Client: Docker Engine - Community
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.20.10
 Git commit:        afdd53b
 Built:             Thu Oct 26 09:08:02 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.10
  Git commit:       311b9ff
  Built:            Thu Oct 26 09:08:02 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.26
  GitCommit:        3dd1e886e55dd695541fdcd67420c2888645a495
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    24.0.7
 Context:    default
 Debug Mode: false

Server:
 Containers: 27
  Running: 27
  Paused: 0
  Stopped: 0
 Images: 109
 Server Version: 24.0.7
 Storage Driver: btrfs
  Btrfs:
 Logging Driver: syslog
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dd1e886e55dd695541fdcd67420c2888645a495
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.0-16-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 30.85GiB
 Name: sagittarius
 ID: SYST:ZGOX:264T:44KN:XQGE:BJIQ:3FGI:ZVOF:VRG3:GCYP:QEIY:EP5Q
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions