Docker网络强制清理(docker-compose场景下的问
2021-04-10 本文已影响0人
流雨声
docker网络无法删除
docker 网络出问题了,然后使用命令进行删除,结果报错:
Error response from daemon: error while removing network...
问题追踪
[root@harbor harbor]# docker network ls
NETWORK ID NAME DRIVER SCOPE
93f0ec306ab5 bridge bridge local
821031255cda harbor_harbor bridge local
[root@harbor harbor]# docker network rm 821031255cda
Error response from daemon: error while removing network: network harbor_harbor id 821031255cdaf4909913c8a1c9451db461e898a877661564f59cd13f4d0d68b5 has active endpoints
解决方法如下
[root@harbor harbor]# docker network inspect harbor_harbor
[
{
"Name": "harbor_harbor", #参数一
"Id": "821031255cdaf4909913c8a1c9451db461e898a877661564f59cd13f4d0d68b5",
"Created": "2019-11-08T17:16:11.031524353+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": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"98cbc25660b315f0a639d3340aad084b2819d43fc966969316597d42f5b1b84c": {
"Name": "harbor-core", # 参数二
"EndpointID": "254f0dae9697b07294670b596f74e9d95056739d85f75c6722e70c539e50aa86",
"MacAddress": "02:42:ac:12:00:08",
"IPv4Address": "172.18.0.8/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "harbor",
"com.docker.compose.project": "harbor",
"com.docker.compose.version": "1.24.1"
}
}
]
记下上面输出的“参数一”和“参数二”,然后执行如下命令:
docker network disconnect -f harbor_harbor harbor-core
网络技巧延伸
重新run 容器的时候,一直报该容器的名字已经存在,前前后后,还是这样,明明删除成功了,但是run容器的时候,
有提示该容器的名字已经存在,由于内部网络没有释放导致的;
# 关联网络删除再重新创建
docker network disconnect-f bridge 容器名字
总结
每一天一个延伸小技巧呦!!!