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.