moby: DNS lookup error in containers in rootless DIND (VPNkit)

Description

If the upstream DNS server strips out IPv6 addresses, DNS lookups inside containers started in dind-rootless fail with NXDOMAIN even though the response seems to contain a valid IP addresses.

This is easily visible when trying to apk add in alpine containers:

$ docker run -d --privileged --rm --name dind-rootless -it docker:dind-rootless
$ docker exec -it ddt docker -H unix://run/user/1000/docker.sock  run --rm alpine apk add curl
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
bca4290a9639: Pull complete
Digest: sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
Status: Downloaded newer image for alpine:latest
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/main: DNS lookup error
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/community: DNS lookup error
ERROR: unable to select packages:
  curl (no such package):
    required by: world[curl]

The same works correctly when running under regular rootful dind.

I was also able to reproduce the same behavior with 25 and 24 dind images.

Reproduce

EDIT: This only happens when the DNS server strips the IPv6 responses, so you need a setup like: https://github.com/moby/moby/issues/47628#issuecomment-2484654590

$ docker run -d --privileged --rm --name dind-rootless -it docker:dind-rootless
$ docker run -d --privileged --rm --name dind -it docker:dind

$ docker exec -it dind-rootless docker -H unix://run/user/1000/docker.sock  run --rm alpine nslookup alpinelinux.org
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
bca4290a9639: Pull complete
Digest: sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
Status: Downloaded newer image for alpine:latest
Server:         192.168.65.1
Address:        192.168.65.1:53

Non-authoritative answer:
Name:   alpinelinux.org
Address: 213.219.36.190
Name:   alpinelinux.org
Address: 213.219.36.190

** server can't find alpinelinux.org: NXDOMAIN


$ docker exec -it dind docker run --rm alpine nslookup alpinelinux.org
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
bca4290a9639: Pull complete
Digest: sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
Status: Downloaded newer image for alpine:latest
Server:         192.168.65.7
Address:        192.168.65.7:53

Non-authoritative answer:
Name:   alpinelinux.org
Address: 213.219.36.190

Non-authoritative answer:

Expected behavior

DNS lookups should work

docker version

Client:
 Cloud integration: v1.0.35+desktop.12
 Version:           26.0.0
 API version:       1.45
 Go version:        go1.21.8
 Git commit:        2ae903e
 Built:             Wed Mar 20 15:14:46 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.29.0 (143575)
 Engine:
  Version:          26.0.0
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       8b79278
  Built:            Wed Mar 20 15:18:02 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    26.0.0
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1-desktop.1
    Path:     /Users/pawel/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.25.0-desktop.1
    Path:     /Users/pawel/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.27
    Path:     /Users/pawel/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /Users/pawel/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     /Users/pawel/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/pawel/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     /Users/pawel/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/pawel/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.6.3
    Path:     /Users/pawel/.docker/cli-plugins/docker-scout

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: active
  NodeID: pusk8nj7ic0o8sshcfrcwzad0
  Is Manager: true
  ClusterID: fydwewr8u5g3ndgqbakh967r4
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 192.168.65.3
  Manager Addresses:
   192.168.65.3:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 6.6.22-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 7.755GiB
 Name: docker-desktop
 ID: b00f1447-fb88-4bd8-aa26-ed40f28ed7ed
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 101
  Goroutines: 261
  System Time: 2024-03-25T12:24:53.214549167Z
  EventsListeners: 30
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/pawel/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Additional Info

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 9
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

With the addition of the slirp4netns in https://github.com/docker-library/docker/pull/543, I re-ran the test @Vigrond provided at https://github.com/moby/vpnkit/issues/509#issuecomment-2907526284 with the new DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns environment variable configuration:

docker run -e DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns --rm -d --name nstest-dindrootless --privileged docker:dind-rootless
sleep 5
docker exec -it nstest-dindrootless docker -H unix://run/user/1000/docker.sock run --rm alpine /bin/sh -c "apk add bind-tools && dig github.com A github.com AAAA && wget github.com"

And the test now succeeds!

$ docker run -e DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns --rm -d --name nstest-dindrootless --privileged docker:dind-rootless
5678a6f9036055e6f5ed42133df207eb3fecc7ac53e02adeaac9dfbd2f10219e
$ docker exec -it nstest-dindrootless docker -H unix://run/user/1000/docker.sock run --rm alpine /bin/sh -c "apk add bind-tools && dig github.com A github.com AAAA && wget github.com"
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
fe07684b16b8: Pull complete 
Digest: sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715
Status: Downloaded newer image for alpine:latest
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/community/x86_64/APKINDEX.tar.gz
(1/15) Installing fstrm (0.6.1-r4)
(2/15) Installing krb5-conf (1.0-r2)
(3/15) Installing libcom_err (1.47.2-r2)
(4/15) Installing keyutils-libs (1.6.3-r4)
(5/15) Installing libverto (0.3.2-r2)
(6/15) Installing krb5-libs (1.21.3-r0)
(7/15) Installing json-c (0.18-r0)
(8/15) Installing nghttp2-libs (1.65.0-r0)
(9/15) Installing protobuf-c (1.5.2-r0)
(10/15) Installing userspace-rcu (0.15.2-r0)
(11/15) Installing libuv (1.51.0-r0)
(12/15) Installing xz-libs (5.8.1-r0)
(13/15) Installing libxml2 (2.13.8-r0)
(14/15) Installing bind-libs (9.20.10-r0)
(15/15) Installing bind-tools (9.20.10-r0)
Executing busybox-1.37.0-r18.trigger
OK: 15 MiB in 31 packages

; <<>> DiG 9.20.10 <<>> github.com A github.com AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24588
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;github.com.			IN	A

;; ANSWER SECTION:
github.com.		47	IN	A	140.82.113.4

;; Query time: 10 msec
;; SERVER: 10.0.2.3#53(10.0.2.3) (UDP)
;; WHEN: Mon Jul 07 18:07:18 UTC 2025
;; MSG SIZE  rcvd: 55

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8244
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;github.com.			IN	AAAA

;; AUTHORITY SECTION:
github.com.		394	IN	SOA	ns-1707.awsdns-21.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400

;; Query time: 2 msec
;; SERVER: 10.0.2.3#53(10.0.2.3) (UDP)
;; WHEN: Mon Jul 07 18:07:18 UTC 2025
;; MSG SIZE  rcvd: 136

Connecting to github.com (140.82.113.4:80)
Connecting to github.com (140.82.113.4:443)
saving to 'index.html'
index.html           100% |********************************|  280k  0:00:00 ETA
'index.html' saved

I believe this issue should remain open until the DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns setting is the default. I believe others on the same page as noted at https://github.com/docker-library/docker/pull/543

We could perhaps made slirp4netns the default net driver, at-least for moby 29? Any thoughts? cc @AkihiroSuda.