青春须早为 2023-06-03 16:47 采纳率: 0%
浏览 40

Docker容器之间在同一网络中不能ping通

以下都是在vm虚拟机中
主机hosta(192.168.1.83)、主机hostb(192.168.1.84)、主机hostc(192.168.1.85)
主机hosta docker容器 consul
主机hostb docker容器 alpine1 websrv
主机hostc docker容器 alpine2

容器 alpine1 websrv alpine2 属于同一网络“overlaynet”

三个容器都属于overlaynet网络

[root@host-b ~]# docker network inspect -f '{{range .Containers}}{{.Name}} {{end}}' overlaynet
websrv alpine1 alpine2

[root@host-b ~]# docker network inspect overlaynet

[
    {
        "Name": "overlaynet",
        "Id": "8fa1dfbd8d97f8316a1465fd06b524724bcfe3479bd1bbbeec5e0a43d7a70a9f",
        "Created": "2023-06-03T03:57:01.751658193-04:00",
        "Scope": "global",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "10.0.1.0/24",
                    "Gateway": "10.0.1.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "5cb8f891819e38614d881d14a9ba35740e4eb19c1d3fe17e927f1bb6b9aa592e": {
                "Name": "websrv",
                "EndpointID": "4dff1906adae521e01ae84d955c69c9444573859138c3aedc10dbaa5de584414",
                "MacAddress": "02:42:0a:00:01:04",
                "IPv4Address": "10.0.1.4/24",
                "IPv6Address": ""
            },
            "b36262a6dc1eaa03b40215e015460238927b2393027c6b2b017397bd2f63697a": {
                "Name": "alpine1",
                "EndpointID": "227d381e8c886c043feff1b118f3faf2bf482bce71a63488c7a45c59841b7b81",
                "MacAddress": "02:42:0a:00:01:02",
                "IPv4Address": "10.0.1.2/24",
                "IPv6Address": ""
            },
            "ep-147d73e8ef87607da91f79a288129e93d79be06ccbe30888685625ba9d4668f4": {
                "Name": "alpine2",
                "EndpointID": "147d73e8ef87607da91f79a288129e93d79be06ccbe30888685625ba9d4668f4",
                "MacAddress": "02:42:0a:00:01:03",
                "IPv4Address": "10.0.1.3/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.enable_icc": "true"
        },
        "Labels": {}
    }
]

[root@host-b ~]# docker exec alpine1 ping -c2 websrv
PING websrv (10.0.1.4): 56 data bytes
64 bytes from 10.0.1.4: seq=0 ttl=64 time=0.165 ms
64 bytes from 10.0.1.4: seq=1 ttl=64 time=0.114 ms

[root@host-b ~]# docker exec alpine1 ping -c2 www.qq.com
PING www.qq.com (112.53.42.52): 56 data bytes
64 bytes from 112.53.42.52: seq=0 ttl=51 time=33.299 ms
64 bytes from 112.53.42.52: seq=1 ttl=51 time=32.688 ms

#  容器alpine1    ping  hostc     IP正常
[root@host-b ~]# docker exec alpine1 ping -c2 192.168.1.85
PING 192.168.1.85 (192.168.1.85): 56 data bytes
64 bytes from 192.168.1.85: seq=0 ttl=63 time=0.828 ms
64 bytes from 192.168.1.85: seq=1 ttl=63 time=0.491 ms

#   容器alpine1   ping   alpine2  IP能解析出来,但是ping不通,
[root@host-b ~]# docker exec alpine1 ping -c2 alpine2
PING alpine2 (10.0.1.3): 56 data bytes

--- alpine2 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss


问题: 为什么这个不能ping通,firewall   selinux 全部关闭了。求教一下解题思路!!!
  • 写回答

1条回答 默认 最新

  • IT民工金鱼哥 运维领域新星创作者 2023-06-05 11:43
    关注

    有没试过ping IP呢? 先别PING 主机名。

    评论

报告相同问题?

问题事件

  • 创建了问题 6月3日

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择