docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
746 stars 85 forks source link

Container /etc/resolv.conf does not update when /run/systemd/resolve/resolv.conf changes #889

Open seandilda opened 4 years ago

seandilda commented 4 years ago

Expected behavior

When I move my laptop to different networks or join a VPN, the /etc/resolv.conf in the container should update to match my system's new DNS settings.

https://docs.docker.com/v17.09/engine/userguide/networking/default_network/configure-dns/ mentions that there is a change notifier for the host's /etc/resolv.conf so container resolv.conf files will be updated. I'd like to see similar behavior when using systemd-resolved

Actual behavior

After changing networks (ie traveling between home and work), the container's /etc/resolv.conf will reflect the previous DNS settings which results in DNS not working in the container.

Steps to reproduce the behavior

Start a long running container on your laptop (which is using systemd-resolved), then move to a different network with different DNS servers. Notice that the resolv.conf inside the container is now wrong.

Output of docker version:

Client:
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.9
 Git commit:        6a30dfca03
 Built:             Mon Sep 16 03:56:22 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.9
  Git commit:       6a30dfca03
  Built:            Wed Sep 11 22:45:55 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10-0ubuntu1
  GitCommit:        
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit:        

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 18
  Running: 9
  Paused: 0
  Stopped: 9
 Images: 72
 Server Version: 19.03.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: kata-runtime runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.3.0-24-generic
 Operating System: Ubuntu 19.10
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 31.22GiB
 Name: laptop
 ID: GEYE:UHJL:EXIT:AYKR:7JN5:T6XP:PDFU:E2ER:USAE:HFFI:O35F:PQJW
 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

WARNING: No swap limit support
aitorpazos commented 4 years ago

Not exactly the same issue but closely related to https://github.com/moby/moby/issues/38243 as it may be fixed if systemd-resolve support is improved IMO.