[root@dyw219 ~]# docker run --net=host -it centos /bin/bash
[root@dyw219 /]# hostname dyw219
[root@dyw219 /]# 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.089 ms 64 bytes from 172.17.42.1: icmp_seq=2 ttl=64 time=0.065 ms --- 172.17.42.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.065/0.077/0.089/0.012 ms [root@dyw219 /]# 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.085 ms 64 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.065 ms --- 172.17.0.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.065/0.075/0.085/0.010 ms [root@dyw219 /]# 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.093 ms 64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.070 ms --- 172.17.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.070/0.081/0.093/0.014 ms
[root@dyw219 /]# exit exit
[root@dyw219 ~]# docker inspect 9facf9a147fd | grep -i networkmode
"NetworkMode": "host",