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

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 centos7中sudo命令无法使用
  • ¥15 灰狼算法和蚁群算法如何结合
  • ¥15 这是一个利用ESP32自带按键和LED控制的录像代码,编译过程出现问题,请解决并且指出错误,指导如何处理 ,协助完成代码并上传代码
  • ¥20 stm32f103,hal库 hal_usart_receive函数接收不到数据。
  • ¥20 求结果和代码,sas利用OPTEX程序和D-efficiency生成正交集
  • ¥50 求fpga交通信号灯设计Verilog代码
  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联