我有Dockerfile。
[isuser@den01gwe DockerImages]$ cat Dockerfile
FROM oraclelinux:7
CMD ["/bin/bash"]
当我运行图像默认网络(网桥)时,我无法ping通通过--add-host
添加的主机。但是,当我通过主机网络运行它时,我可以ping通主机。桥接网络可能有什么问题?
docker run --rm -it --name masud --add-host=oamhost1.us.oracle.com:10.196.62.185 --add-host=oamhost2.us.oracle.com:10.196.62.186 masud
[root@58e6606fb69f /]# ping oamhost1.us.oracle.com
PING oamhost1.us.oracle.com (10.196.62.185) 56(84) bytes of data.
^C
--- oamhost1.us.oracle.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3102ms
docker run --rm -it --name masud --network=host --add-host=oamhost1.us.oracle.com:10.196.62.185 --add-host=oamhost2.us.oracle.com:10.196.62.186 masud
[root@den01gwe /]# ping oamhost1.us.oracle.com
PING oamhost1.us.oracle.com (10.196.62.185) 56(84) bytes of data.
64 bytes from oamhost1.us.oracle.com (10.196.62.185): icmp_seq=1 ttl=64 time=0.833 ms
64 bytes from oamhost1.us.oracle.com (10.196.62.185): icmp_seq=2 ttl=64 time=0.449 ms
^C
--- oamhost1.us.oracle.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1012ms
rtt min/avg/max/mdev = 0.449/0.641/0.833/0.192 ms