Skip to content

When resolving the Docker Host /etc/hosts is used only after the DNS server #34544

@mtneug

Description

@mtneug

Description

I'm trying to use the docker:edge-dind image and link it to a docker:edge container, but all Docker commands time out and end in an error. The DOCKER_HOST is set properly to tcp://docker:2375 and I'm able to resolve docker to the dind container IP. Using the IP directly works fine. After some search I found docker/for-mac#1302, which describes the same error. Docker seems to first ask the DNS server and only than use the /etc/hosts file. Sadly, in my environment the DNS server is able to resolve docker (plus search domain). However, I would expect that the hosts file has precedence.

Steps to reproduce the issue:

  1. docker run --privileged --name docker -d docker:edge-dind
  2. docker run -it --link docker docker:edge sh
  3. docker version

Describe the results you received:

Docker resolves the IP using a DNS server, which returns a wrong IP. The command outputs an error after a timeout.

Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:15:15 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?

Describe the results you expected:

Docker uses the /etc/hosts file to resolve the domain name to get the correct IP.

Output of docker version:

Client:
 Version:      17.07.0-ce-rc2
 API version:  1.31
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:43:03 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.07.0-ce-rc2
 API version:  1.31 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:48:34 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 12
 Running: 2
 Paused: 0
 Stopped: 10
Images: 39
Server Version: 17.07.0-ce-rc2
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 logentries splunk syslog
Swarm: active
 NodeID: 192b3389rd5w5h7xofpludtr6
 Is Manager: true
 ClusterID: kj6e2ug0n2d0fww991efqi4k7
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Root Rotation In Progress: false
 Node Address: 192.168.65.2
 Manager Addresses:
  192.168.65.2:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3addd840653146c90a254301d6c3a663c7fd6429
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.41-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 7
Total Memory: 13.68GiB
Name: moby
ID: IV5F:MZJI:EVWO:YUWY:G37K:C777:KW7N:L5MW:BUVT:HLHF:CUVL:NDB7
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 51
 Goroutines: 166
 System Time: 2017-08-17T12:32:07.53965267Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

The command output above is using Docker for Mac, but I first saw that error in an Linux environment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions