当我创建网络时,它可以正常工作。
[root@localhost ~]# docker run --net=br1 --ip=192.168.0.119 -ti --name=doc 328edcd84f1b /bin/bash
[root@8f5c0179d86a /]# ping www.baidu.com
PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
64 bytes from 115.239.210.27 (115.239.210.27): icmp_seq=1 ttl=55 time=10.8 ms
但是当我重新启动主机(或重启docker)时,它无法启动容器
我显示网络列表,它在那里,但错误消息告诉我它不存在
我的码头版本是1.12.6
[root@localhost ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
e83fa9afc6af br1 bridge local
2fb7bed3e5ba bridge bridge local
984a5e65f182 host host local
d8e8ce860225 none null local
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker network inspect br1
[
{
"Name": "br1",
"Id": "e83fa9afc6af2cf01b0b0103d0c98d7334717cdd5290e2121dc03a5d6b48aa84",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.0.0/24",
"IPRange": "192.168.0.0/24",
"Gateway": "192.168.0.120"
}
]
},
"Internal": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.name": "br0",
"parent": "ens33"
},
"Labels": {}
}
]
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f5c0179d86a 328edcd84f1b "/bin/bash" 2 hours ago Exited (137) 56 minutes ago doc
2492467008a0 328edcd84f1b "/bin/bash" 2 hours ago Exited (127) 2 hours ago mytest1
a3c7184a4bf5 328edcd84f1b "/bin/bash" 17 hours ago Exited (0) 17 hours ago awesome_perlman
f1e26864c870 328edcd84f1b "/bin/bash" 18 hours ago Exited (128) 17 hours ago berserk_kalam
ce2d1b7a6ce2 328edcd84f1b "/bin/bash" 18 hours ago Exited (1) 2 hours ago lonely_banach
[root@localhost ~]# docker start doc
Error response from daemon: failed to create endpoint doc on network br1: network e83fa9afc6af2cf01b0b0103d0c98d7334717cdd5290e2121dc03a5d6b48aa84 does not exist
Error: failed to start containers: doc