compose icon indicating copy to clipboard operation
compose copied to clipboard

DNS resolution fails with docker compose (but not docker)

Open io7m opened this issue 2 years ago • 3 comments

Description

I'm unable to get any kind of DNS resolution inside a container started with docker-compose. The same problem does not occur when using the plain docker command.

The closest related issue I could see was https://github.com/docker/compose/issues/8598, but that didn't appear to have a satisfying resolution. I've tried every combination of dns and network type, and can't get anything useful to happen. I'm using systemd-networkd and systemd-resolved on the system and have no issues with DNS resolution elsewhere.

Steps to reproduce the issue:

See this repos: https://github.com/io7m/docker-compose-issue-20220609

  1. Confirm that docker build . works correctly. Delete the image afterwards to avoid any cache issues.
  2. Edit docker-compose.yml to use a dns entry with a server you can actually reach (like 8.8.8.8); My LAN only allows DNS requests to the server specified in the example dns entry, by design.
  3. Run docker-compose up --build. DNS resolution for the apt-get command fails.

Describe the results you received:

Any kind of DNS resolution fails. Inspection shows that /etc/resolv.conf is nonexistent, and some casual spying with wireshark shows that no DNS requests appear to be made.

Describe the results you expected:

DNS resolution works as it does with docker build.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

Docker Compose version 2.6.0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., 2.6.0)

Server:
 Containers: 5
  Running: 2
  Paused: 0
  Stopped: 3
 Images: 9
 Server Version: 20.10.16
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 96df0994faabc1944fc614e52b0b3c6feb609a57.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.18.2-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 45.08GiB
 Name: hazelnut
 ID: UHCO:STBI:DF6D:NAGE:5OKG:TZ7T:DDAA:PDIE:EGFG:D7BX:PXKI:G5SC
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Linux hazelnut 5.18.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 06 Jun 2022 19:58:58 +0000 x86_64 GNU/Linux

io7m avatar Jun 09 '22 16:06 io7m

I have experienced the same issue, also using Arch and everything recently updated:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., 2.6.0)

Server:
 Containers: 13
  Running: 13
  Paused: 0
  Stopped: 0
 Images: 50
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 96df0994faabc1944fc614e52b0b3c6feb609a57.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.18.3-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 28
 Total Memory: 31.26GiB
 Name: archsrv1
 ID: CNYM:VNTG:3ZZL:HDWZ:TO6Z:GO56:2WGX:MGH6:D2P6:GV7Y:EHS4:MFFC
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Uklosk avatar Jun 12 '22 10:06 Uklosk

Same here on CentOS8 (Docker Compose version v2.6.0) and Mac (Docker Compose version v2.5.1).

Note:

  • Using a specific docker compose build also exhibits the same problem
  • A reliable workaround is to docker compose down and docker compose up -d after the build and first run.

maharg101 avatar Jun 14 '22 11:06 maharg101

Also observed on Ubuntu 22

Output of docker compose version

Docker Compose version v2.6.0

Output of docker info

Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:02:46 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:00:51 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

maharg101 avatar Sep 07 '22 11:09 maharg101

The same thing happens when using Docker under Ubuntu's Multipass under Mac OS X 13 (with the local docker command aliased to multipass exec docker docker where the name of the Multipass instance is 'docker').

The Multipass VM is running Ubuntu 22.04.

Output of 'docker-compose version`

Docker Compose version v2.11.1

Output of docker info

 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.11.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 20
  Running: 2
  Paused: 0
  Stopped: 18
 Images: 116
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.0-52-generic
 Operating System: Ubuntu 22.04.1 LTS
 OSType: linux
 Architecture: aarch64
 CPUs: 2
 Total Memory: 7.743GiB
 Name: docker
 ID: FWXL:FFLV:XD4C:LKYN:TBNN:DFF5:MBXG:WND3:MX2Z:ZGP2:Q64K:DXMB
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

yaffol avatar Nov 23 '22 10:11 yaffol

Can you please confirm you get the same issue building this Dockerfile when using docker buildx build . (or alternatively DOCKER_BUILDKIT=1 docker build .)? Otherwise, this should be reported to https://github.com/docker/buildx/issues

For use with compose, as a workaround you can run DOCKER_BUILDKIT=0 docker compose build to use the classic builder

ndeloof avatar Dec 09 '22 09:12 ndeloof

I'm having the same issue but on Windows 11:

Docker compose version Docker Compose version v2.12.2

Output for docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.12.2)
  dev: Docker Dev Environments (Docker Inc., v0.0.3)
  extension: Manages Docker extensions (Docker Inc., v0.2.13)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 4
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.15.74.2-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 5.791GiB
 Name: docker-desktop
 ID: 57Q4:K5VN:EP3B:3GNS:462K:T4ZT:T7AS:KKNE:7B5G:5JN5:JU2C:YBUX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

@ndeloof I can confirm that docker buildx build fails witht he same error as docker compose up

failed to solve: ubuntu:18.04: failed to do request: Head "https://registry-1.docker.io/v2/library/ubuntu/manifests/18.04": dial tcp: lookup registry-1.docker.io on 192.168.65.5:53: read udp 172.17.0.2:59645->192.168.65.5:53: i/o timeout

@ndeloof you know the workaround for windows?

AffiTheCreator avatar Dec 09 '22 15:12 AffiTheCreator

You can run DOCKER_BUILDKIT=0 docker compose build to force use of the "classic" builder, anyway I suggest you report this bug to the buildx team

ndeloof avatar Dec 09 '22 16:12 ndeloof