I have a system with several docker-compose containers and networks. Occasionally, when we do a docker-compose down, it fails with the error: ERROR: error while removing network: network broker_net-conquest id 94bc69b11c077471717c2d2ab457d5e4010086ba80ad528cc4cc03772bc1da37 has active endpoints
But, if I try to find the container with the active endpoint, there are none:
Iâve taken over this issue. Iâve run docker-compose down --remove-orphans and that has not resolved the issue. Still seeing the following error:
ERROR: error while removing network: network broker_net-conquest id 1b6a38f8fda17d1412a7445e1b8bbcf7c4495fb62874c686f852378ffbf7fb07 has active endpoints
Has anyone run into this recently ? Apart from restarting docker daemon and deleting the network I did not find any solution ? What if in the scenarios where docker daemon cannot be restarted how to fix this ?
I had the same issue and apparently it was caused by changes in the docker-compose file which I made after docker compose up command, when I changed it back to the original state docker compose down worked fine.
I had an endpoint, so docker network disconnect -f <network> <endpoint> worked for me, but other folks without endpoints suggested that docker system prune helped.
Looks like a race condition, where it tries to remove the network, before all containers attached to it are removed. Eventually all resources in the compose project should be removed, so it should be rather a cosmetic problem. Though,
If the above problem creates a problem in a script, you can make it wait until all resources are actually removed
PROJECT="$(basename $PWD)"
for resource_type in container network; do
until [ -z "$(docker $resource_type ls --filter label=com.docker.compose.project="${PROJECT}" -q)" ]; do
sleep 1
done
done
Note: the snippet either needs to be executed in the folder where the compose file is stored, or if a project name is provided through parameters, it needs to be set instead.
Though, the only use case where it might make sense to me is if you want to run docker compose down followed by a docker compose up -d in a script or pipeline.
Docker compose down --remove-orphans doesnât work. Bringing down all services and all containers and running docker system prune doesnât workâŠ
Using docker inspect on the network I donât see any containers (in fact ALL containers are down).
But still I get:
failed to remove network docker_xxx_network: Error response from daemon: error while removing network: network docker_xxx_network id 05245b263250edde24645a1c0f51b26d18591aab684fb73e7148c1d574b1493d has active endpoints
I had this problem and eventually found a solution.
I had obviously started some/all of the containers not using the compose file. I manually stopped each container and then removed it. Now I restarted the whole system using docker-compose up -d. after that point docker-compose down worked just fine
Any way to debug this starting from the immediate error message - âhas active endpointsâ.
What is an âendpointâ? I would assume itâs a container⊠but if docker network inspect shows âContainersâ: {} then what is being enumerated to come to the conclusion that there are active endpoints?
This is an old issue originally about Docker Compose v1. It probably had a bug which caused what @meyay described
If you get the error message, that indeed means a container is still using that network, but eventually comose deletes it after getting the error message so you donât see the container anymore. If you run it multiple times, and still get the error message, then you either had multiple networks and inspected the wrong one, or there is another bug somehwre. But in that case it is more likely you are still using Docker Compose v1 instead of v2.
Inspect the network using docker network inspect {network_id}
Locate the container-id from response and then stop the container docker stop {conatiner-id}
then you can do docker-compose down --remove-orphans