docker network create --driver bridge network1
docker run -itd --name docker1 --network network1 busybox
docker run -itd --name docker2 --network network1 busybox
docker exec -it docker1 /bin/bash
现在在docker1中,我可以ping docker2
/ # ping docker2
PING docker2 (172.19.0.3): 56 data bytes
64 bytes from 172.19.0.3: seq=0 ttl=64 time=0.056 ms
我以为这个条目是在/etc/hosts中添加的,但它不是
/ # cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
172.19.0.2 841c0dc99115