docker network 删除失败 has active endpoint

关于docker-compose down 时出现network 删除失败,存在endpoint 的问题
用inspect 查看 network是否存在 相关的endpoint-name 存在表示有正在使用它的container
如果有,用disconnect 来断连,再删除
往往是没有的,最终重启docker,再删除解决,原因估计是状态的同步 存在问题,未及时清楚关联记录。
操作步骤如下:

error while removing network: XXX has active endpoint
docker network inspect {network}获得{endpoint-name},即docker-compse.yml中的container_name

docker network inspect my-network
[
    {
        "Name": "my-network",
        "Id": "596c41e9de4b8e604ff0907a9975fb19b87fe9a32b7b3b14761521a4ca5ee803",
        "Created": "2023-12-03T14:11:24.384930596Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.23.0.0/16",
                    "Gateway": "172.23.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "7496537f896d847fe36c9adb6fdee2fbd8eb1d79b45301b965b34b94cd66d248": {
                "Name": "redis",
                "EndpointID": "3e75f795aa625a0f194434fba8405f4d166576952a789424fc633b9189ff278e",
                "MacAddress": "02:42:ac:17:00:04",
                "IPv4Address": "172.23.0.4/16",
                "IPv6Address": ""
            },
            "91f6c5951e3bb8334a489352f7e82e412f6858e017490cd8b646a53f992fafe2": {
                "Name": "minio",
                "EndpointID": "392f98e407304ccb0c738d8207135bd6430b64beb13ee01f8dd07a471a776de9",
                "MacAddress": "02:42:ac:17:00:03",
                "IPv4Address": "172.23.0.3/16",
                "IPv6Address": ""
            },
            "b45c6cd455c07877d8506b3d5af0883d5636d740c052fd957e93bc8c128b16ac": {
                "Name": "mysql8",
                "EndpointID": "23cf1fae340629d4902d9742f5947c928dd1af27d6ba9fbf87527b01d107d176",
                "MacAddress": "02:42:ac:17:00:05",
                "IPv4Address": "172.23.0.5/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "my-network",
            "com.docker.compose.project": "sg-exam",
            "com.docker.compose.version": "2.17.2"
        }
    }
]


docker network disconnect -f {network} {endpoint-name}

docker network disconnect -f my-network mysql8

docker network disconnect -f my-network minio

docker network disconnect -f my-network redis

docker network rm my-network 删除docker network

重启docker-compose up -d
关闭docker-compose down
发现进程依然存在,已经造成假死
docker进行stop,失败
最终,重启docker解决sudo service docker restart 然后再删除就可以成功了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值