moby: Unable to remove network "has active endpoints"
Not to sure if this belongs in this repo or libnetwork.
docker version: Docker version 1.9.0-rc1, build 9291a0e
docker info:
Containers: 0
Images: 5
Engine Version: 1.9.0-rc1
Storage Driver: devicemapper
Pool Name: docker-253:0-390879-pool
Pool Blocksize: 65.54 kB
Base Device Size: 107.4 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 2.023 GB
Data Space Total: 107.4 GB
Data Space Available: 11.62 GB
Metadata Space Used: 1.7 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.146 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.14.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 2
Total Memory: 1.797 GiB
Name: carbon1.rmb938.com
ID: IAQS:6E74:7NGG:5JOG:JXFM:26VD:IAQV:FZNU:E23J:QUAA:NI4O:DI3S
uname -a: Linux carbon1.rmb938.com 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Sep 15 15:05:51 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
List the steps to reproduce the issue:
- Create a network with a remote driver
- Run a container connected to the network
- Kill and Remove the container
- Remove the network
Describe the results you received:
If the remote network driver gives an error when processing /NetworkDriver.Leave docker still kills and removes the container but does not remove the endpoint. This allows docker’s internal db to think that the endpoint still exists even though the container is removed.
When you try and remove the network this error is returned
docker network rm net1
Error response from daemon: network net1 has active endpoints
Describe the results you expected:
Docker should not be allowed to kill or remove the container if /NetworkDriver.Leave returned an error.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 89 (18 by maintainers)
Commits related to this issue
- wip: Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.co... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- wip: Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.co... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- wip: Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.co... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- Fix tests to handle deadlocks with docker networks Avoid errors like https://github.com/Tecnativa/doodba-copier-template/runs/1917653981?check_suite_focus=true#step:13:214 See https://github.com/mob... — committed to Tecnativa/doodba-copier-template by joao-p-marques 3 years ago
- fix: always remove orphans Apply workaround from https://github.com/moby/moby/issues/17217#issuecomment-815334656 to see if it fixes those nasty errors in CI. In any case, it seems sensible and safe... — committed to Tecnativa/doodba-copier-template by deleted user 3 years ago
- fix: always remove orphans Apply workaround from https://github.com/moby/moby/issues/17217#issuecomment-815334656 to see if it fixes those nasty errors in CI. In any case, it seems sensible and safe... — committed to Tecnativa/doodba-copier-template by deleted user 3 years ago
- fix: always remove orphans Apply workaround from https://github.com/moby/moby/issues/17217#issuecomment-815334656 to see if it fixes those nasty errors in CI. In any case, it seems sensible and safe... — committed to Tecnativa/doodba-copier-template by deleted user 3 years ago
- fix: always remove orphans Apply workaround from https://github.com/moby/moby/issues/17217#issuecomment-815334656 to see if it fixes those nasty errors in CI. In any case, it seems sensible and safe... — committed to Tecnativa/doodba-copier-template by deleted user 3 years ago
- fix: always remove orphans Apply workaround from https://github.com/moby/moby/issues/17217#issuecomment-815334656 to see if it fixes those nasty errors in CI. In any case, it seems sensible and safe... — committed to Tecnativa/doodba-copier-template by deleted user 3 years ago
- Try to fix "network has active endpoints" issue https://github.com/moby/moby/issues/17217#issuecomment-815334656 — committed to mediacloud/backend by pypt 3 years ago
- examples: Add `--remove-orphans` when bringing down examples This might resolve a very infrequent CI bug in which docker doesnt clean up containers before removing the network. This relates to a ver... — committed to phlax/envoy by phlax 2 years ago
- examples: Add `--remove-orphans` when bringing down examples (#22702) This might resolve a very infrequent CI bug in which docker doesnt clean up containers before removing the network. This rela... — committed to envoyproxy/envoy by phlax 2 years ago
- examples: Add `--remove-orphans` when bringing down examples (#22702) This might resolve a very infrequent CI bug in which docker doesnt clean up containers before removing the network. This rela... — committed to maistra/envoy by phlax 2 years ago
@keithbentrup This is a stale endpoint case. Do you happen to have the error log when that container that was originally removed (which left the endpoint in this state). BTW, if the container is removed, but the endpoint is still seen, then one can force disconnect the endpoint using
docker network disconnect -f {network} {endpoint-name}
. You can get the endpoint-name from thedocker network inspect {network}
command.This issue seems to be very intermittent and does not happen very often.
Encountered this issue. I’m on linux (mint), and restarting docker fixed the issue for me:
Awesome. Thanks.
docker service restart fixed the problem for me.
@keithbentrup thats correct. as I suggested earlier. the
docker network disconnect -f {network} {endpoint-name}
… pls use the endpoint-name. We can enhance this to support endpoint-id as well. But I wanted to confirm that by using the force option, were you able to make progress.Or
sudo reboot -f
. Works 100%.I may have the same problem with
docker 1.13.0
.Since no-one in this thread have given an example of just what I did, I’ll post it.
For completes, this is the error that starts it. It may be because I have
codekitchen/dinghy-http-proxy:2.5.0
which listens on port 80.And trying to bring it all down:
And how I killed the network:
why is this issue closed? It has never been fixed and still happens very regularly, still after multiple
docker-compose down -v
what exactly is the mentioned
endpoint
considered here?@danwdart Another reason for this is when there are dangling containers. in order to remove them, use the command
docker-compose down --remove-orphans
that should do the trick.@mavenugo
This worked for me .
I just experienced the bug that makes impossible to remove a network that has no containers attached to. Restarting the docker daemon solved the issue. Thank you @davidroeca!
What if the “endpoint” no longer exists? What if there are NO containers whatsoever (
docker container ls -a
shows NOTHING), but I STILL get this error?When no command works then do
sudo service docker restart
your problem will be solvedI’ve just reproduced this issue with docker v1.11.2 while attempting
docker-compose down
. An earlier attempt to rundocker-compose down
did close the app_front network.docker info
See this ref for faster resolution Docker removal examples
@mavenugo If by
docker network disconnect -f {network} {endpoint-name}
you meandocker network disconnect [OPTIONS] NETWORK CONTAINER
perdocker network disconnect --help
, I tried that, but it complained (not surprisingly) withNo such container
.If you meant the
EndpointID
instead of the container name/id, I did not try that (but will next time) because that’s not what the--help
suggested.For a closed issue this ticket is rather active. Just had a situation where
docker-compose -f file down
finished with the error in question but there was no active (or any) endpoint. Restarting docker service fixed allowed removing the network.Was brought here because of the same issue. I appended
--remove-orphans
and it was fixedI’m seeing the same problem when attempting to remove a stack:
I had first created the stack like so:
Am using this version:
Luckily,
sudo service docker restart
fixes it, but still not ideal behavior.@mavenugo sorry for the delay. I’m not using docker multi-host networking afaik. Its a single node raspberry pi and I haven’t done anything other than install docker via hypriot.
Here’s the output you requested (
network
is the network I can’t delete)The kv file is attached, I had to name it .txt to get around github filters, but its the binary file.
local-kv.db.txt
I created the network via direct API calls (dockerode)
This has worked (create and delete) numerous times, I think in this instance, I
docker rm -f <container-id>
but I’m not positive, I might have power-cycled the machine…Hope that helps. –brendan
Restarting docker didn’t do the trick for me. Added
--remove-orphans
option todocker-compose down
and the network was successfully removed.Hello from 2019, @mavenugo I would like to pass on my sincere, sincere thanks for having the solution on this one back in 2016.
Thanks for sharing your fix, @Wallace-Kelly. Adding a
--project-name
to mydocker-compose up
anddocker-compose down
commands fixed the “network has active endpoints” error for me. 👍still seeing these “orphaned networks” can you reopen @rmb938 @thaJeztah
Error response from daemon: network abcd_default id 3f2f1a6cb1cee2d82f2e2e59d10a099834a12b18eb7e3e48d6482d758bd93617 has active endpoints
only way to prune them seems to be restarting the engine
@mavenugo Yes, I’m using the overlay driver via docker-compose with a swarm host managing 2 nodes.
When I
docker network inspect
the network on each individual node, 1 node had 1 container listed that no longer existed and so could not be removed bydocker rm -fv
using the container name or id.Same issue happening in our ci pipeline. This is happening too often now a days and failing out pipelines. docker-compose down with --remove-orphans also same issue. Restarting docker is the only solution now and retriggering the jobs .
I have this error running airflow.
Running
fixed it.
I needed to just run
docker-compose rm
-docker-compose down
is what I normally do andps -a
showed no containers so this really tripped me up until I ran therm
cmd. Thought I’d share.i had a similar issue today. what i did was i ran “docker container ls -a” and saw few containers still running were utilizing the network which i had launched via docker stack. so manually when i killed those containers i was able to delete the network
Encountered it in 17.07.0-ce,
disconnect
approach did not work, then restarted docker and runrm
again with success.I also just reproduced this in 1.10.3 and landed here via google looking for a work around. I can’t force disconnect the active endpoints b/c none of the containers listed via
docker network inspect
still exist.I eventually had to recreate my consul container and restart the docker daemon.
Another thank you @mavenugo here from 2020
This is still reproducable on
Docker version 18.06.1-ce, build e68fc7a
Seems that even when the containers of a compose file are removed, their endpoints are sometimes not removed, which can sometimes happen on power loss, so composes fail to either completely start or completely remove.Good luck today
I’ve run into this with a 17.06-ce swarm cluster too; running out of options besides rebooting.
@nicolaiskogheim has a valid solution. However, my team has a docker-compose file with ~20 containers. So I found another solution.
I’d like to throw in that you can also restart the docker daemon (e.g.
systemctl restart docker
on centos) and then the links between network and containers will be gone. You can thendocker system prune -f
with success.docker-compose down --remove-orphans Removing network test_default ERROR: error while removing network: network test_default id 4169314d8c79786bd7ed0a9d8df9a153ee26827f9b00f582c4fd981019bc2137 has active endpoints
seeing a similar issue, albeit very very intermittently in CI (for https://github.com/envoyproxy/envoy) for an example that scales backend services
for ref, the related compose file is here https://github.com/envoyproxy/envoy/blob/main/examples/locality-load-balancing/docker-compose.yaml
and the script that is testing it in CI is here https://github.com/envoyproxy/envoy/blob/main/examples/locality-load-balancing/verify.sh
im going to add the
--remove-orphans
flag, altho as this happens so infrequently it wont be easy to see if it helpsyes you are correct, I just found the solution myself and uninstalled the snap version. Added a description for others that run into the problem. Thank you for the fast response @thaJeztah 😃
Solution: The different server version made it suspicious. Found a working solution for me: https://askubuntu.com/a/1315837/1199816 .In my case, our admin installed docker during the ubuntu setup, which made a snap installation. But, as an experienced long-term ubuntu / debian user, I installed docker using the command line as usual. Apt list will only show the packages installed via apt and do not show the snap packages! Now, two separate versions of the docker server run side-by-side and the docker client connects either to one of the competing background servers - with the side-effect that only one has the running containers and the other told me there are no running containers with docker ps. I just uninstalled the snap version (we are not using snap by default) and everything is working fine and is up-to-date. I just leave my post here to help others.
Old post with error behavior: Still an issue. I can specify it further. The containers seem to run “hidden” and are accessible from the internet. But, docker ps just show one or two containers (out of 7) in my application. Now, if I want to docker-compose down the file, the network cannot be removed because of the containers running “hidden”. What I have recognized earlier is, if you uninstall docker completely and reinstall it from the ground, the containers are attached backed and you can simply down them and remove the network. Nevertheless, this cannot be the intended behavior. As a side-effect, you cannot “up” the compose file because it throws an error that the ports are in use or:
ERROR: for db Cannot create container for service db: failed to mount local volume: mount /digLab/GG/db:/var/snap/docker/common/var-lib-docker/volumes/dbdata/_data, flags: 0x1000: no such file or directory
I am on Ubuntu 20.04 LTS, with:
This is still an issue after more than four years. Is there some simpler way of disconnecting every container from every network they are connected to than a 10±line shell script? FWIW this seems to work:
In summary:
I end up with the same problem, as the network was not able to remove with all acctions , noting helped. my version is Docker version 18.09.6, build 481bc77
To fix, i have restart docker services. by “sudo service docker restart” after that i able to remove with “docker network rm {network}”
sudo service docker restart
gets rid of it for me on ubuntu, allowing me to deploy & start my containers again.Also works if one of the containers refuses to get killed (happens more than I’d hope). Annoying as it makes me bring all services down because of one mischievous container.
@keithbentrup @brendandburns thanks for raising the issue. Couple of questions
docker network ls
output./var/lib/docker/network/files/local-kv.db
file (via some file-sharing website) and whichnetwork
are you trying to remove ? And how was the network originally created ?FYI. for a multi-host network driver, docker maintains the endpoints for a network across the cluster in the KV-Store. Hence, if any host in that cluster still has an endpoint alive in that network, we will see this error and this is an expected condition.