DEV Community

Diego Carrasco Gubernatis
Diego Carrasco Gubernatis

Posted on • Originally published at diegocarrasco.com on

1 1

How to remove a network with active endpoints in Docker

Problem: ERROR: error while removing network

I wanted to run docker-compose down but it failed due to the following error:

ERROR: error while removing network: network <your\_network> id cfcb4a603426f2cf71b1f971a9ecb0aae7e6c889a8dc4c55bfd1eb010d8a260b has active endpoints

Enter fullscreen mode Exit fullscreen mode

Solution

To solve this just run docker network inspect <your_network> with the rights permissions. (You may also use sudo if you have the permission).

The output of that command is something like this:

[
    {
        "Name": "your\_network",
        "Id": "cfcb4a603426f2cf71b1f971a9ecb0aae7e6c889a8dc4c55bfd1eb010d8a260b",
        "Created": "2021-05-05T10:58:08.216143067+02:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.38.0/24",
                    "Gateway": "10.0.38.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "cf8f158e34d07bb3be8ff73e21fc688dce1ba13a5b941a7a59aff1373a74be8f": {
                "Name": "phpmyadmin\_phpmyadmin\_1",
                "EndpointID": "e77d58d75ee31a37ee2cced2658c36480c4f209d8eedf29d4d281f8073457eb1",
                "MacAddress": "02:42:0a:00:26:05",
                "IPv4Address": "10.0.38.5/24",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "your\_project",
            "com.docker.compose.version": "1.28.5"
        }
    }
]

Enter fullscreen mode Exit fullscreen mode

In this case the network is your_network and the endpoint is in containers -> name.

Now you can use sudo docker network disconnect -f your_network phpmyadmin_phpmyadmin_1. This will disconnect the network from the instance, and you will be able to run docker-compose down without problems.

Source: This answer in Stack Overflow

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay