Docker Community Forums

Share and learn in the Docker community.

Docker for windows: pinging container from host

Hello guys.

Docker rookie here, so please be patient :slight_smile:

Ok, so I鈥檝e installed docker for windows (Windows 10 Enterprise 1903 build 18362.30):

位 docker version
Client: Docker Engine - Community
Version: 19.03.2
API version: 1.40
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:26:49 2019
OS/Arch: windows/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.2
API version: 1.40 (minimum version 1.24)
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:39:49 2019
OS/Arch: windows/amd64
Experimental: false

I鈥檝e set it up to use windows containers and I鈥檝e pulled and run an image with IIS (nanoserver version):

位 docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
microsoft/iis nanoserver d4d34a16ef9d 10 months ago 1.29GB

My container is up and running with the 81:80 port mapping:

位 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4116c7bc329c microsoft/iis:nanoserver 鈥淐:\ServiceMonitor.e鈥︹ 3 hours ago Up 21 minutes 0.0.0.0:81->80/tcp iis

Now, my problem is that I can鈥檛 ping the container from the host. I鈥檝e used the inspect command to get the container鈥檚 IP Address:

位 docker inspect 6

鈥淣etworks鈥: {
鈥渘at鈥: {
鈥淚PAMConfig鈥: null,
鈥淟inks鈥: null,
鈥淎liases鈥: null,
鈥淣etworkID鈥: 鈥渂b2fb449d958ebe6662089b0fb2ea40c8f423d3480f6e5a5b8353cf14b0121af鈥,
鈥淓ndpointID鈥: 鈥43362eaaaf4750e44abe98c9967795af316e79361b5914cd2e5ff5507d757946鈥,
鈥淕ateway鈥: 鈥172.31.176.1鈥,
鈥淚PAddress鈥: 鈥172.31.181.72鈥,
鈥淚PPrefixLen鈥: 16,
鈥淚Pv6Gateway鈥: 鈥溾,
鈥淕lobalIPv6Address鈥: 鈥溾,
鈥淕lobalIPv6PrefixLen鈥: 0,
鈥淢acAddress鈥: 鈥00:15:5d:55:69:ce鈥,
鈥淒riverOpts鈥: null
}
}
}
}
]

Here鈥檚 the output of the ping command:

位 ping 172.31.181.72

Pinging 172.31.181.72 with 32 bytes of data:
Reply from 10.200.2.222: Destination net unreachable.
Reply from 10.200.2.222: Destination net unreachable.
Reply from 10.200.2.222: Destination net unreachable.
Reply from 10.200.2.222: Destination net unreachable.

Ping statistics for 172.31.181.72:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

I鈥檝e tried running tracert and I鈥檝e noticed that it鈥檚 being sent to the default gateway (instead of going to the docker鈥檚 nat):
位 tracert 172.31.181.72

Tracing route to 172.31.181.72 over a maximum of 30 hops

1 <1 ms <1 ms <1 ms 10.51.2.126
2 <1 ms <1 ms <1 ms 10.200.202.126
3 * * * Request timed out.
4 <1 ms <1 ms <1 ms 10.200.2.217
5 10.200.2.222 reports: Destination net unreachable.

Trace complete.

And here鈥檚 my routing table:
位 route print

Interface List
9鈥c 22 0b 8a 3a 40 鈥ntel庐 82579LM Gigabit Network Connection
12鈥00 19 86 00 3c 1b 鈥luetooth Device (Personal Area Network)
1鈥oftware Loopback Interface 1
15鈥00 15 5d db 0d fb 鈥yper-V Virtual Ethernet Adapter
25鈥00 15 5d 55 61 52 鈥yper-V Virtual Ethernet Adapter #2

IPv4 Route Table

Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.51.2.126 10.51.2.7 281
10.51.2.0 255.255.255.128 On-link 10.51.2.7 281
10.51.2.7 255.255.255.255 On-link 10.51.2.7 281
10.51.2.127 255.255.255.255 On-link 10.51.2.7 281
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
172.17.71.224 255.255.255.240 On-link 172.17.71.225 5256
172.17.71.225 255.255.255.255 On-link 172.17.71.225 5256
172.17.71.239 255.255.255.255 On-link 172.17.71.225 5256
172.31.176.0 255.255.240.0 On-link 172.31.176.1 5256
172.31.176.1 255.255.255.255 On-link 172.31.176.1 5256
172.31.191.255 255.255.255.255 On-link 172.31.176.1 5256
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 10.51.2.7 281
224.0.0.0 240.0.0.0 On-link 172.17.71.225 5256
224.0.0.0 240.0.0.0 On-link 172.31.176.1 5256
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 10.51.2.7 281
255.255.255.255 255.255.255.255 On-link 172.17.71.225 5256
255.255.255.255 255.255.255.255 On-link 172.31.176.1 5256

Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 10.51.2.126 Default

IPv6 Route Table

Active Routes:
If Metric Network Destination Gateway
1 331 ::1/128 On-link
9 281 fe80::/64 On-link
15 5256 fe80::/64 On-link
25 5256 fe80::/64 On-link
25 5256 fe80::203a:130f:411b:b8fa/128
On-link
15 5256 fe80::9164:82e9:9a09:4a13/128
On-link
9 281 fe80::c853:9e31:3cb3:d087/128
On-link
1 331 ff00::/8 On-link
9 281 ff00::/8 On-link
15 5256 ff00::/8 On-link
25 5256 ff00::/8 On-link

Persistent Routes:
None

I鈥檓 not a network guy, but it looks like everything is ok. I鈥檝e tried installing docker for windows on another machine and everything works as expected without any additional configurations.

Any clues on what鈥檚 going on with this machine? Can anyone point me on the right direction?

Thanks.

Regards,
Luis

Ok, just adding more info鈥

After rebooting, the ips have changed, but I鈥檝e also noticed something weird: the IP I get from the docker inspect container_id is different from the one I get on the machine.

位 docker inspect 6
鈥淣etworks鈥: {
鈥渘at鈥: {
鈥淚PAMConfig鈥: null,
鈥淟inks鈥: null,
鈥淎liases鈥: null,
鈥淣etworkID鈥: 鈥11117ac2f84721d1ca93c719192dd4d2aa5f9e6d23e7b3077dfd8ffb63aaf2e2鈥,
鈥淓ndpointID鈥: 鈥渃7eac036cb3037b092a28cb8d1b6cb532c388192f6410361665c950fcaad48c5鈥,
鈥淕ateway鈥: 鈥172.23.160.1鈥,
鈥淚PAddress鈥: 鈥172.23.175.99鈥,
鈥淚PPrefixLen鈥: 16,
鈥淚Pv6Gateway鈥: 鈥溾,
鈥淕lobalIPv6Address鈥: 鈥溾,
鈥淕lobalIPv6PrefixLen鈥: 0,
鈥淢acAddress鈥: 鈥00:15:5d:33:8c:be鈥,
鈥淒riverOpts鈥: null
}
}

位 docker exec -it 6 powershell
Windows PowerShell
Copyright 漏 2016 Microsoft Corporation. All rights reserved.

PS C:> ipconfig

Windows IP Configuration

Ethernet adapter Ethernet:

Connection-specific DNS Suffix . : mshome.net
Link-local IPv6 Address . . . . . : fe80::19e6:caeb:2e4c:32d5%4
IPv4 Address. . . . . . . . . . . : 192.168.238.61
Subnet Mask . . . . . . . . . . . : 255.255.255.240
Default Gateway . . . . . . . . . : 172.23.160.1
192.168.238.49
PS C:>

Any ideas on what鈥檚 going on here?

Hello again.

After playing a little more with it, I鈥檝e went with the docker network prune (which deleted the default switch) and now everything seems to be working fine鈥