Docker Community Forums

Share and learn in the Docker community.

Host.docker.internal mapped to an outdated IP Address

beta
docker

(Mornemaritz) #1

Hi,

I’m experiencing an issue where the special DNS name, host.internal.docker, seems to resolve to an outdated IP Address.

This feature initially worked for me. The DNS name resolved to the IP Address 192.168.204.29 and the container was able to successfully connect to a database server running on the host.

However, somewhere in the process changing networks on my host machine (connecting to my home network and subsequently reconnecting to the office network) which, I’m assuming caused a fresh IP Address to be assigned to my machine by DHCP, access from the container to the host was lost.

I’ve subsequently found that the DNS name host.internal.docker is still resolving to 192.168.204.29 even though this IP Address is no longer mapped on my host.

I’ve tried the following to force a refresh of the IP Address mapped to host.internal.docker:

  • Remove the container
  • Remove the image
  • Rebuild the image with the --no-cache option
  • Reset Docker
  • Reinstall Docker for Windows

docker version output:

Client:
  Version:      18.05.0-ce
  API version:  1.37
  Go version:   go1.9.5
  Git commit:   f150324
  Built:        Wed May  9 22:16:13 2018
  OS/Arch:      linux/amd64
  Experimental: false
  Orchestrator: swarm
 
 Server:
  Engine:
   Version:      18.05.0-ce
   API version:  1.37 (minimum version 1.12)
   Go version:   go1.10.1
   Git commit:   f150324
   Built:        Wed May  9 22:20:16 2018
   OS/Arch:      linux/amd64
   Experimental: true

docker info output

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 2
Server Version: 18.05.0-ce
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: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d03b107
ID: BSLU:JLHM:SIAU:UFPE:6WT3:ZK3R:X7D6:QU37:435Q:75BK:H3KG:3YM4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 20
 Goroutines: 36
 System Time: 2018-07-16T09:02:27.9941247Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

What I’ve done to confirm the outdated IP Address

  • created a container in WSL (Windows Subsystem for Linux) by executing docker container run ...
  • fired up bash in the container docker container exec -it {container-name} bash
  • execute ping host.docker.internal
  • nothing happens.
  • when I eventually kill the process (crt+c) I see the following:
--- host.docker.internal ping statistics ---
19 packets transmitted, 0 received, 100% packet loss, time 18687ms
  • created a docker container with access to the host network:
    docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
  • execute nslookup host.docker.internal
  • output from above:
/ # nslookup host.docker.internal
nslookup: can't resolve '(null)': Name does not resolve

Name:      host.docker.internal
Address 1: 192.168.204.29
  • switch to the host and execute the same:
/ # chroot /host
/ # nslookup host.docker.internal
nslookup: can't resolve '(null)': Name does not resolve

Name:      host.docker.internal
Address 1: 192.168.204.29
/ #

output from ipconfig on the host (windows)

λ ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : MorneMa-PC
   Primary Dns Suffix  . . . . . . . : entelect.local
   Node Type . . . . . . . . . . . . : Broadcast
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : entelect.local

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller
   Physical Address. . . . . . . . . : 20-47-47-59-54-94
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (DockerNAT):

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-03-B1-06
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 10.0.75.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Disabled

Wireless LAN adapter Local Area Connection* 12:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #3
   Physical Address. . . . . . . . . : 12-C0-90-61-2A-F5
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Local Area Connection* 13:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #4
   Physical Address. . . . . . . . . : 22-C0-90-61-2A-F5
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Dell Wireless 1802 802.11a/b/g/n Adapter
   Physical Address. . . . . . . . . : B0-C0-90-61-2A-F5
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::f1a9:3ccf:f86e:f682%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.0.250(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, 16 July 2018 09:37:03
   Lease Expires . . . . . . . . . . : Monday, 16 July 2018 10:02:02
   Default Gateway . . . . . . . . . : 192.168.0.1
   DHCP Server . . . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 45138064
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-22-8B-7D-55-58-8A-5A-1C-82-AB
   DNS Servers . . . . . . . . . . . : 8.8.8.8
                                       8.8.4.4
                                       208.67.222.222
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
   Physical Address. . . . . . . . . : B0-C0-90-61-2A-F6
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (Default Switch):

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : E6-15-D1-A9-35-52
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::143e:bd8c:683e:ce6%11(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.19.3.177(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 805311837
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-22-8B-7D-55-58-8A-5A-1C-82-AB
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Disabled

Ethernet adapter vEthernet (nat):

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
   Physical Address. . . . . . . . . : 00-15-5D-25-0A-D7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::394c:a18a:d363:f0e8%16(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.30.240.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 1023415645
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-22-8B-7D-55-58-8A-5A-1C-82-AB
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Disabled