首页 > 数据库 >docker启动创建容器时,报错Cannot link to /mysql, as it does not belong to the default network

docker启动创建容器时,报错Cannot link to /mysql, as it does not belong to the default network

时间:2023-03-04 19:44:56浏览次数:50  
标签:容器 network default 网络 -- 报错 link docker

  • 启动创建容器时,报错Cannot link to /mysql, as it does not belong to the default network
  • 从报错信息看是不属于默认网络
  • 分析容器网络
    • 通过docker inspect 容器id 先后查看应用容器更新之前网络、报错应用容器网络、mysql容器网络、redis容器网络
      • 发现应用容器更新之前的gateway都为172.18.0.1

         

      • 报错应用容器网络的网关为172.17.0.1

        

    • 由上步得知,网络确实不一致,需要修改默认网络

      • 先查找容器内网络信息docker network ls

        

    • 接下来查看具体的网络信息docker network inspect 网络id
      • bridge网络截图

        

      • local_default 截图

        

  • 接下来创建时指定网络
    docker run -id --name  miaosha3.1    -p 7080:7080   --net="local_default"  --link mysql  \ 
    --link rabbitmq --link redis:myRedis \
    -v /etc/localtime:/etc/localtime:ro \
    镜像地址不写了
    • --net="link使用的网络"
  • 成功解决

  

 

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back

标签:容器,network,default,网络,--,报错,link,docker
From: https://www.cnblogs.com/u-damowang1/p/17178904.html

相关文章