-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Problem Description
I've created an docker container
[root@shadow ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c097871dfc7d centos:latest "/bin/bash" 5 minutes ago Up 5 minutes cenots
[root@shadow ~]# docker inspect cenots
The container IP is :
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
My local network IP is :
ifconfig
docker1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
inet6 fe80::42:99ff:fed3:d338 prefixlen 64 scopeid 0x20
ether 02:42:99:d3:d3:38 txqueuelen 0 (Ethernet)
RX packets 14 bytes 1064 (1.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 54 bytes 6005 (5.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
But I cannot ping each other.
[root@shadow ~]# ping 172.18.0.2
PING 172.18.0.2 (172.18.0.2) 56(84) bytes of data.
From 172.18.0.1 icmp_seq=1 Destination Host Unreachable
From 172.18.0.1 icmp_seq=2 Destination Host Unreachable
From 172.18.0.1 icmp_seq=3 Destination Host Unreachable
From 172.18.0.1 icmp_seq=4 Destination Host Unreachable
However, when I tcpdump the docker1, the ping works.
tcpdump -i docker1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on docker1, link-type EN10MB (Ethernet), capture size 262144 bytes
03:26:18.034854 ARP, Request who-has 172.18.0.2 tell 172.18.0.1, length 28
03:26:18.034888 ARP, Reply 172.18.0.2 is-at 02:42:ac:12:00:02 (oui Unknown), length 28
03:26:18.034901 IP 172.18.0.1 > 172.18.0.2: ICMP echo request, id 15891, seq 1, length 64
03:26:18.034943 IP 172.18.0.2 > 172.18.0.1: ICMP echo reply, id 15891, seq 1, length 64
03:26:19.035138 IP 172.18.0.1 > 172.18.0.2: ICMP echo request, id 15891, seq 2, length 64
03:26:19.035195 IP 172.18.0.2 > 172.18.0.1: ICMP echo reply, id 15891, seq 2, length 64
03:26:20.035107 IP 172.18.0.1 > 172.18.0.2: ICMP echo request, id 15891, seq 3, length 64
03:26:20.035162 IP 172.18.0.2 > 172.18.0.1: ICMP echo reply, id 15891, seq 3, length 64
03:26:21.035108 IP 172.18.0.1 > 172.18.0.2: ICMP echo request, id 15891, seq 4, length 64
03:26:21.035175 IP 172.18.0.2 > 172.18.0.1: ICMP echo reply, id 15891, seq 4, length 64
03:26:22.035097 IP 172.18.0.1 > 172.18.0.2: ICMP echo request, id 15891, seq 5, length 64
03:26:22.035160 IP 172.18.0.2 > 172.18.0.1: ICMP echo reply, id 15891, seq 5, length 64
03:26:23.047044 ARP, Request who-has 172.18.0.1 tell 172.18.0.2, length 28
ping 172.18.0.2
PING 172.18.0.2 (172.18.0.2) 56(84) bytes of data.
64 bytes from 172.18.0.2: icmp_seq=1 ttl=64 time=0.136 ms
64 bytes from 172.18.0.2: icmp_seq=2 ttl=64 time=0.102 ms
64 bytes from 172.18.0.2: icmp_seq=3 ttl=64 time=0.101 ms
64 bytes from 172.18.0.2: icmp_seq=4 ttl=64 time=0.112 ms
64 bytes from 172.18.0.2: icmp_seq=5 ttl=64 time=0.106 ms
Im so confused about this, how could this happen?