[root@dyw219 ~]# docker inspect 0d30277f64dd | grep 172
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.2",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.2",
[root@dyw219 ~]# docker run --net=container:0d30277f64dd -it centos /bin/bash [root@0d30277f64dd /]#
[root@0d30277f64dd /]# ping -c2 172.17.42.1 PING 172.17.42.1 (172.17.42.1) 56(84) bytes of data. 64 bytes from 172.17.42.1: icmp_seq=1 ttl=64 time=0.129 ms 64 bytes from 172.17.42.1: icmp_seq=2 ttl=64 time=0.080 ms --- 172.17.42.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.080/0.104/0.129/0.026 ms [root@0d30277f64dd /]# ping -c2 172.17.0.1 PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data. 64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.156 ms 64 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.087 ms --- 172.17.0.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.087/0.121/0.156/0.036 ms [root@0d30277f64dd /]# ping -c2 172.17.0.2 PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data. 64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.063 ms 64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.058 ms --- 172.17.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.058/0.060/0.063/0.008 ms
[root@0d30277f64dd /]# exit exit
[root@dyw219 ~]# docker start 0d30277f64dd 0d30277f64dd
[root@dyw219 ~]# docker inspect 0d30277f64dd | grep -i networkmode
"NetworkMode": "bridge",
[root@dyw219 ~]# docker inspect 0d30277f64dd | grep 172
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.2",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.2",