-
Notifications
You must be signed in to change notification settings - Fork 138
Docker in Docker (dind) container linking problem on macOS #1302
Description
Expected behavior
docker info should just work:
$ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
...
Actual behavior
docker info cannot resolve the hostname docker, but it works fine it pointed directly to the IP address:
$ docker info
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
$ export DOCKER_HOST='tcp://172.17.0.2:2375'
$ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
...
Information
Docker for Mac: version: 1.13.1 (94675c5a7)
macOS: version 10.12.3 (build: 16D32)
logs: /tmp/70A59DC6-BF23-4515-BC34-03CC59FF47A3/20170214-181939.tar.gz
[OK] vmnetd
[OK] dns
[OK] driver.amd64-linux
[OK] virtualization VT-X
[OK] app
[OK] moby
[OK] system
[OK] moby-syslog
[OK] db
[OK] env
[OK] virtualization kern.hv_support
[OK] slirp
[OK] osxfs
[OK] moby-console
[OK] logs
[OK] docker-cli
[OK] menubar
[OK] disk
Steps to reproduce the behavior
In the macOS Terminal:
docker run -d --name docker --privileged docker:1.13-dind
docker run -ti --rm --name client --link docker:docker docker:1.13 /bin/sh
In the second container's shell:
$ docker info
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
$ ping -c 1 docker
PING docker (172.17.0.2): 56 data bytes
64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.120 ms
$ export DOCKER_HOST='tcp://172.17.0.2:2375'
$ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: vfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5 (containerized)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952 GiB
Name: 04032b297320
ID: 6SVY:P6MV:EIGT:PCWX:KXLL:2VX6:C62Y:ERUL:3AJL:3X3T:KXPV:SKEZ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
The cause - but only on Mac?
In the second container:
$ cat /etc/resolv.conf
# Generated by dhcpcd from eth0.dhcp
# /etc/resolv.conf.head can replace this line
nameserver 192.168.65.1
# /etc/resolv.conf.tail can replace this line
$ ping -c 1 192.168.65.1
PING 192.168.65.1 (192.168.65.1): 56 data bytes
64 bytes from 192.168.65.1: seq=0 ttl=37 time=0.630 ms
$ strace -f docker info
...
connect(3, {sa_family=AF_INET, sin_port=htons(2375), sin_addr=inet_addr("81.200.64.50")}, 16) = -1 EINPROGRESS (Operation in progress)
...
$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 docker 04032b297320
172.17.0.3 ad3d5606774c
Where does 192.168.65.1 come from? I seem able to ping many addresses that are unpingable from the host (4.4.4.4, 254.254.254.254, 1.3.3.7, ...)
Why is it resolving 'docker' to '81.200.64.50'?
Going to that IP I get a Virgin Media page. I'm with Virgin Media coincidentally. It says something about 'Advanced Network Error Search', but I've never seen that ever before.
In the corner it says: This service is optional and you can switch it off here
So I clicked on it:
WTF IS THAT?
I switch to 'No' and... HURRAH! Magically and immediately the problem is gone. I don't even have to restart any containers...
Why do I get this only on my Macs? It doesn't happen in Linux.
