moby: docker network rm `networkname` has error has active endpoints
Description when running
$ docker network rm new-mail_develop_default
error response from daemon: error while removing network: network new-mail_develop_default id 469e10dee4acb100fb868d7709bd83c75beeded79962cc574d47976495668d89 has active endpoints
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
1183956ec66a bridge bridge local
1c98ceffa4d4 host host local
469e10dee4ac new-mail_develop_default bridge local
4826ed19a910 none null local
$ docker network inspect new-mail_develop_default
[
{
"Name": "new-mail_develop_default",
"Id": "469e10dee4acb100fb868d7709bd83c75beeded79962cc574d47976495668d89",
"Created": "2021-03-08T12:28:54.020954486+03:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.0.0/20",
"Gateway": "192.168.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "new-mail_develop",
"com.docker.compose.version": "1.27.4"
}
}
]
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Steps to reproduce the issue:
- Cannot be reproduce special case
Describe the results you received: remove network
Describe the results you expected: remove network
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker version:
Docker version 20.10.3, build 48d30b5
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 72
Server Version: 20.10.3
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1160.15.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.51GiB
Name: up-jenkins01.pusula.net.tr
ID: TAN6:P6A4:CLRY:GP46:6CLZ:RBUT:YO3V:I2AF:YXRB:26ON:UX3D:ZJYC
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.): proxmox
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 26
- Comments: 32 (4 by maintainers)
Commits related to this issue
- tests: do not use docker volumes Why: * This bug happens infrequently: https://github.com/moby/moby/issues/42119 * This causes networks to not be removed at the end of a test. * This causes volumes ... — committed to wazo-platform/wazo-setupd by sduthil 5 years ago
- Merge pull request #42 from wazo-platform/tests-without-volumes tests: do not use docker volumes Why: This bug happens infrequently: moby/moby#42119 This causes networks to not be removed at the en... — committed to wazo-platform/wazo-setupd by wazo-community-zuul[bot] 5 years ago
We have the same issue on a non proxmox environment
while no container is attached
and not even a single container exists
Seems to be happening with the new docker engine, 18.xx seems to work just fine. Fairly blocking since it reoccurs frequently.
There is no way to fix this issue besides restarting the docker-engine itself. We neither can do either of this
docker network prune --forcedocker network rm testing_default@sonersivri you should probably rename the issue to include ‘while no containers exist’ because there are a couple of other issues with ‘still active endpoints’ which actually have attached containes - which we do not have here and that should be an important difference
@EugenMayer There are cases where the issue is related to what users do, for instance when there’s an orphaned Compose container left over, or a container manually connected to a Compose network. In those cases, the improved error message will help users determine what’s going on.
I recognize this is probably not the most prominent cause.
It’s more than probable that there’s a low-level bug lying around somewhere… This is what I wrote in #49736:
Some of the design decisions that led to this are related to the the eventually-consistent nature of remote datastores used by Classic Swarm.
Classic Swarm went out-of-support 5 years ago, and yet we’re still repaying some of its tech debt. It’s a pitty, I know.
With #49736, we’re bypassing the afflicted code-path, so hopefully the user-facing bug (i.e. “has active endpoints” when it’s not) will be fixed. I can’t be sure, because I don’t have any simple repro that be can transformed into a regression test…
The findings in this comment are interesting: https://github.com/moby/moby/issues/42119#issuecomment-1398975494. It matches the hypothesis I made in #49736 – i.e. the
EndpointCntstruct goes out of sync with the on-diskEndpoint. But it also talks about on-diskEndpointthat actually do not exist… So I can’t tell for sure.Fortunately this PR is also putting us on the right track to gradually fix the concurrency model by letting more code-paths bypass the faulty data-persistence layer.
Just hit an even worse repro of this issue. This time, restarting docker (or the entire system) did not resolve the issue. The rogue docker network was not visible in the output of
docker network ls. However, thebr-...interface still showed up in the output ofifconfig.docker network inspect <...>on that network returned nothing. Tried force deleting the interface withip link delete br-.... Upon reboot, the interface was recreated. Still didn’t show up in the output ofdocker network ls.The solution we found was to delete the file
/var/lib/docker/network/files/local-kv.dband reboot. Thanks to @jest for pointing me in the right direction with your analysis.Really hope someone at docker can look at this issue, it’s a rather serious bug.
Docker Version
docker --version Docker version 20.10.7, build f0df350
on Ubuntu 18.04.5
Restating the daemon works
@akerouanton i’am not sure it is argueable at all, that this is a bug. This is a bug.
#49736 / #49773 might finally fix the bug with the “active endpoints” that do actually not exists, that plague so many people and even forced us to restart the docker engine every time we shutdown the application stack (before we upgrade). Happily, we have a single stack per docker engine … this is not possible for all the people out there. This bug exists since years and is as important as “you cannot upgrade via
dc pull && dc up” without hands on any longer. The bug i’am talking about is #23302 … has been closed without ever being fixed.Just happened to me as well. I solved it by restarting docker service, I can do that right now since this is a new server setup but wont be able to in the future once we have services running.
For the record, I’ve made two changes in this area in the past week:
Hopefully the 2nd change will help users figure if the error is legit (e.g. an orphaned Compose container is still running), or if this is caused by a bug.
These changes will be available in the next release (v28.1). We’ll build an RC1 tomorrow, so it should be available soon.
@EugenMayer that might be a trace… I just realized that the error occurs on my two server machines, where the backing filesystem for
/var/lib/dockeris XFS…I don’t know about the popularity of such a choice, but quite a few of the reports in the above comments also mention XFS.
This might be the issue with bbolt itself, where some of the assumptions it has e.g. about low-level filesystem behavior does not hold for either BTRFS or XFS.
We are also seeing this issue on Rocky Linux 8
After restarting the docker daemon, I am able to remove the network. Running
docker system prune --forcedoesn’t help for me.@jest: Thanks for the detailed look into it. I also had the hunch, that is was tracking the number of containers in the network via some variable which it fails to decrement to zero and then it refuses to remove the container because it only checks that value at that point.
I also think there are concurrent database accesses which mess up that value resulting in an inconsistency.
You are also correct that this issue exists for quite some time already. You can find people all over the internet running into it and the only “solution” is to restart
dockerd…Maybe with your detailed information someone is willing to dig into it and find the offending database interactions.
Some other workaround that I have found:
We are doing this for 6 weeks now and haven’t hit the bug again. We might be lucky, or this is another workaround without shutting down
dockerd.We’re seeing this same issue as well with docker 20.10.5. We have a CI/CD that is spawning hundreds of dockers and with docker 19.03 we never had issues with “docker-compose down” reporting active endpoints. We recently upgraded to docker 20.10.5 and we’re hitting this problem tens of times per day on that CI/CD pipeline.
Let me know if there’s any log I can collect to help debugging this issue.