Error response from daemon: error while removing network

created at 05-29-2022 views: 10

problem

[root@harbor harbor]# docker network ls
NETWORK ID     NAME              DRIVER    SCOPE
9157e7c5d410   bridge            bridge    local
ab6f7cf13d65   docker_gwbridge   bridge    local
21c637f7e2dc   host              host      local
vfm1j6220xsf   ingress           overlay   swarm
f4e637839398   my-network        bridge    local
0225c9bc65b2   none              null      local

[root@harbor harbor]# docker network rm f4e637839398
Error response from daemon: error while removing network: network my-network id f4e637839398a11549ff8a187f41ec90351f65d35c1c09d32561db6e19471335 has active endpoints

solution

[root@master conf]# docker network inspect my-network
[
    {
        "Name": "my-network",  //parameter1
        "Id": "f4e637839398a11549ff8a187f41ec90351f65d35c1c09d32561db6e19471335",
        "Created": "2022-05-29T09:08:34.980602237+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.1.0/16",
                    "Gateway": "192.168.1.0"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "c69773af2e73cb0b80ee9d3f41352b022681219f5a20cdddeba377e61ddc361c": {
                "Name": "tomcat-net-99",  //parameter2
                "EndpointID": "24d1aa31b5510c009a51452fa6b301bcfcacdba6f299d342dc081242c4933a06",
                "MacAddress": "02:42:c0:a8:00:02",
                "IPv4Address": "192.168.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
[root@master conf]# docker network disconnect -f my-network tomcat-net-99
// here my-network is the parameter 1 above
// tomcat-net-99 is parameter 2 above

After successful execution, continue to execute the following command

[root@master conf]# docker network rm f4e637839398
f4e637839398
[root@master conf]# docker network ls
NETWORK ID     NAME              DRIVER    SCOPE
9157e7c5d410   bridge            bridge    local
ab6f7cf13d65   docker_gwbridge   bridge    local
21c637f7e2dc   host              host      local
vfm1j6220xsf   ingress           overlay   swarm
0225c9bc65b2   none              null      local
created at:05-29-2022
edited at: 05-29-2022: