Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

Windows ping 不通虚拟机里面的docker

|----------------------------------------|
|                                        |
|   |--------------------------------|   |
|   |                                |   |
|   |    docker(CentOS) 172.18.0.2   |   |
|   |--------------------------------|   |
|                                        |
| Virtual Machine(CentOS) 192.168.27.143 |
|----------------------------------------|

         Windows 192.168.137.123

Windows 可以 ping 虚拟机

虚拟机 可以 ping Windows

虚拟机 可以 ping docker

Docker 可以 ping 虚拟机

Docker 可以 ping Windows

但是 WINDOWS 不可以 PING DOCKER(request time out)

在虚拟机ifconfig

[root@docker ~]# ifconfig
br-fff1cd703408: 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:7bff:fe3f:7669  prefixlen 64  scopeid 0x20<link>
        ether 02:42:7b:3f:76:69  txqueuelen 0  (Ethernet)
        RX packets 5  bytes 378 (378.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1480 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:b6:b4:25:97  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.27.143  netmask 255.255.255.0  broadcast 192.168.27.255
        inet6 fe80::5634:e3d1:16db:c070  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ee:e9:81  txqueuelen 1000  (Ethernet)
        RX packets 434  bytes 41635 (40.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 289  bytes 32577 (31.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 3  bytes 312 (312.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 312 (312.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethdd8e4ad: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::e467:dcff:fe56:3d24  prefixlen 64  scopeid 0x20<link>
        ether e6:67:dc:56:3d:24  txqueuelen 0  (Ethernet)
        RX packets 5  bytes 378 (378.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1480 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

在docker ifconfig

[root@master /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.2  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:ac:12:00:02  txqueuelen 0  (Ethernet)
        RX packets 31  bytes 2530 (2.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1428 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker commit -m "hadoop" -a "hxp" def8faf07d6b hxp/hadoop:1.0

docker network create --driver=bridge --subnet=172.18.0.0/16 hadoop-net

docker run -itd -h master --name master --network hadoop-net --privileged -v /opt/docker:/opt/docker --ip 172.18.0.2 -p 50070:50070 -p 8088:8088 hxp/hadoop:1.0 /usr/sbin/init

我尝试了在Windows route add ,但是还是不行

route add 172.18.0.0 mask 255.255.0.0 192.168.27.143


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ping使用ICMP协议需要双向通信,你还需要在docker里面添加访问windows网络的路由。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...