我无法启动我的一个容器,因为网络中有一个旧版本的容器卡住了。
当我尝试启动容器(使用 docker-compose)时docker-compose up -d service_name
出现以下错误:
Creating project_service_name_1 ... error
ERROR: for project_service_name_1 Cannot start service service_name: endpoint with name project_service_name_1 already exists in network host
ERROR: for service_name Cannot start service service_name: endpoint with name project_service_name_1 already exists in network host
ERROR: Encountered errors while bringing up the project.
当我检查host
网络时,我得到有一个容器连接到网络的信息docker network inspect host
:
[
{
"Name": "host",
"Id": "...",
"Created": "2020-10-19T10:59:34.995303624+02:00",
"Scope": "local",
"Driver": "host",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": []
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476": {
"Name": "project_service_name_1",
"EndpointID": "26d6e12b6983b57527cae6445d30ba35bf7aa9038b7b7877842c4d2ee961079e",
"MacAddress": "",
"IPv4Address": "",
"IPv6Address": ""
},
...
},
"Options": {},
"Labels": {}
}
]
docker network disconnect host project_service_name_1
第一次返回 0(成功)但不会从主机网络中删除 project_service_name_1。第二次我得到:
Error response from daemon: container 4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a is not connected to the network host
所以我猜它是从网络中删除了4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a
(38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476
尽管4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a
之前没有出现在主机网络中)
断开容器的旧 ID 不起作用,因为它不再存在docker network disconnect host 38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476
:
Error response from daemon: No such container: 38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476
我也无法重新创建host
网络,因为它是预定义的docker network rm host
:
Error response from daemon: host is a pre-defined network and cannot be removed
我该如何摆脱网络中容器的记忆?