解决docker网络错误(network bridge not found)
作者:临江仙我亦是行人
这篇文章主要介绍了解决docker网络错误(network bridge not found)问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
问题
docker 没有网络模型了
root@sh-gpu102:~# docker run -it -d -v /mnt:/mnt -v /ssd:/ssd registry.test.cn/more/lite:2.7.0.1542.4e07369 dece9b6df7a13285a53877dc016f518a7657abbe9c03c861a34ec1472b7789b3 docker: Error response from daemon: network bridge not found. root@sh-gpu102:~# docker network ls NETWORK ID NAME DRIVER SCOPE root@sh-gpu102:~#
重启大法
root@sh-gpu102:~# systemctl restart docker
不好使?
root@sh-gpu102:~# docker network ls NETWORK ID NAME DRIVER SCOPE root@sh-gpu102:~#
只能自定义网桥了
root@sh-gpu102:~# docker network create --driver bridge --subnet 172.200.0.0/16 --gateway 172.200.0.1 ai-bridge 9029d91739e65fde98bf737e615ec484410370c74ee7582ed6727c7dad4517dd root@sh-gpu102:~# docker network ls NETWORK ID NAME DRIVER SCOPE 9029d91739e6 ai-bridge bridge local
创建容器
root@sh-gpu102:~# docker run -it -d -v /mnt:/mnt -v /ssd:/ssd --net ai-bridge registry.test.cn/more/lite:2.7.0.1542.4e07369 b0ca771aa2cf1945e469c835b43beb0e3ca279867a20e9035fa218ec04ee65f8 # 查看容器状态 root@sh-gpu102:~# docker ps |grep b0ca771aa b0ca771aa2cf registry.test.cn/more/lite:2.7.0.1542.4e07369 "/bin/bash" About a minute ago Up About a minute brave_galois # 进入容器验证网络 root@sh-gpu102:~# docker exec -it b0ca771aa /bin/bash root@b0ca771aa2cf:~/body_front# ping www.baidu.com PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data. 64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=47 time=2.19 ms 64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=47 time=2.07 ms 64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=3 ttl=47 time=2.05 ms 64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=4 ttl=47 time=2.17 ms 64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=5 ttl=47 time=2.04 ms ^C --- www.a.shifen.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4004ms rtt min/avg/max/mdev = 2.040/2.108/2.194/0.080 ms root@b0ca771aa2cf:~/body_front#
有一个缺点就是
必须指定网络模型
虽说 bridge 是 docker 的默认网络模型
但是自定义的显然没有取代 docker 默认的 bridge
root@sh-gpu102:~# docker run -it -d -v /mnt:/mnt -v /ssd:/ssd registry.test.cn/more/lite:2.7.0.1542.4e07369 dd6d3102d1156253dcb6221087dd3799efaeff9b46873d19fb6b1eeda17b93e0 docker: Error response from daemon: network bridge not found. root@sh-gpu102:~#
至于为什么没有网络模型了,此问题没有找到根本原因,只能等待以后再查了
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。