inch-whf 2022-06-24 20:22 采纳率: 85.7%
浏览 28
已结题

docker 容器内`ping container_name`失败

docker 容器内ping 另一个容器明失败

  1. 涉及容器
  • qinglong
  • jupyter
    qinglong里 ping jupyter
  1. 失败代码
[root@iZbp18y7b5jm99960ajdloZ ~]# docker exec -it qinglong ping jupyter
ping: bad address 'jupyter'
  1. 两容器正常启动

    [root@iZbp18y7b5jm99960ajdloZ ~]# docker ps -a
    CONTAINER ID   IMAGE                          COMMAND                  CREATED        STATUS                      PORTS                                        NAMES
    17dcadac93e1   zookeeper:3.4.9                "/docker-entrypoint.…"   7 hours ago    Up 7 hours                  2888/tcp, 0.0.0.0:2181->2181/tcp, 3888/tcp   zookeeper
    350c27dd6d07   jupyter/datascience-notebook   "tini -g -- start-no…"   7 weeks ago    Up 24 hours (healthy)       0.0.0.0:8888->8888/tcp                       jupyter
    287d6170e13c   whyour/qinglong:2.12           "./docker/docker-ent…"   7 weeks ago    Up 24 hours                 0.0.0.0:15700->5700/tcp                      qinglong
    b7d81a4a3fd8   redis:5.0.14                   "docker-entrypoint.s…"   2 months ago   Exited (137) 25 hours ago                                                redis
    8d34783feaa8   mysql:5.7.37                   "docker-entrypoint.s…"   2 months ago   Up 24 hours                 0.0.0.0:3306->3306/tcp, 33060/tcp            mysql2
    [root@iZbp18y7b5jm99960ajdloZ ~]# 
    
  2. 两容器在同一张网卡

    [root@iZbp18y7b5jm99960ajdloZ ~]# docker network inspect bridge
    [
     {
         "Name": "bridge",
         "Id": "42ebf518e86e4ca08ee47c0a7d3839d9c23ef24d1e3511d2bdfdaf65975327f9",
         "Created": "2022-06-23T20:07:55.613373918+08:00",
         "Scope": "local",
         "Driver": "bridge",
         "EnableIPv6": false,
         "IPAM": {
             "Driver": "default",
             "Options": null,
             "Config": [
                 {
                     "Subnet": "172.18.0.0/16",
                     "Gateway": "172.18.0.1"
                 }
             ]
         },
         "Internal": false,
         "Attachable": false,
         "Ingress": false,
         "ConfigFrom": {
             "Network": ""
         },
         "ConfigOnly": false,
         "Containers": {
             "17dcadac93e10da4c52b11867c42450a99a6c4848e397a0b7cab6d1b9c142f75": {
                 "Name": "zookeeper",
                 "EndpointID": "713126dd4481f6cce80fd8cfaba13239807716bbbd028466b3e35a05b1cfc901",
                 "MacAddress": "02:42:ac:12:00:05",
                 "IPv4Address": "172.18.0.5/16",
                 "IPv6Address": ""
             },
             "287d6170e13c90e9446c4988287cc0bdac06a1ec2776d208564e20b52002fc1a": {
                 "Name": "qinglong",
                 "EndpointID": "a987e4aacb11aab4c3b38979e2b87b75bc2abb6352dbc8dc3622b6b837c4897f",
                 "MacAddress": "02:42:ac:12:00:02",
                 "IPv4Address": "172.18.0.2/16",
                 "IPv6Address": ""
             },
             "350c27dd6d07ab89bdd63005beb86df886cf4f660be816d10968ebd985651aea": {
                 "Name": "jupyter",
                 "EndpointID": "c530c13ebd5c20c2deb3d94db62701b976317d63d36576b7f21a7a08335ecae3",
                 "MacAddress": "02:42:ac:12:00:04",
                 "IPv4Address": "172.18.0.4/16",
                 "IPv6Address": ""
             },
             "8d34783feaa8a2d8ee465d8b494b045c51e9c21f4be176dcda68b4d8ea2b293a": {
                 "Name": "mysql2",
                 "EndpointID": "f2d99e85aa50e79fa67f323f9b81f86db44ee8c82c84409a02f3dea68b2c56d1",
                 "MacAddress": "02:42:ac:12:00:03",
                 "IPv4Address": "172.18.0.3/16",
                 "IPv6Address": ""
             }
         },
         "Options": {
             "com.docker.network.bridge.default_bridge": "true",
             "com.docker.network.bridge.enable_icc": "true",
             "com.docker.network.bridge.enable_ip_masquerade": "true",
             "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
             "com.docker.network.bridge.name": "docker0",
             "com.docker.network.driver.mtu": "1500"
         },
         "Labels": {}
     }
    ]
    [root@iZbp18y7b5jm99960ajdloZ ~]# 
    
  • 写回答

1条回答 默认 最新

  • inch-whf 2022-06-25 09:13
    关注

    那张网卡是docker0,重新换一个网卡就好了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 7月3日
  • 已采纳回答 6月25日
  • 创建了问题 6月24日

悬赏问题

  • ¥15 串口发送数据和接收数据
  • ¥15 JNA调用DLL报堆栈溢出错误(0xC00000FD)
  • ¥15 请教SGeMs软件的使用
  • ¥15 自己用vb.net编写了一个dll文件,如何只给授权的用户使用这个dll文件进行打包编译,未授权用户不能进行打包编译操作?
  • ¥50 深度学习运行代码直接中断
  • ¥20 需要完整的共散射点成像代码
  • ¥15 编写vba代码实现数据录入工作
  • ¥15 做过TCL海信电视小米电视相关影视会员软件私我
  • ¥15 Mapreduce是正常的,在运行其他jar包时并没有任何问题,只是在做LogCount.jar 时出的问题。如图所示
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。