In our team, we are currently transitioning to Docker to deploy everything on our server.
We are using Docker Swarm and multiple (10+) compose files defining plenty (20+) of services. Everything works beautifully so far, except when we take down our stack using docker stack rm <name>
(and redeploy using docker stack deploy <options> <name>
): about every second time, we get the following error:
Failed to remove network <id>: Error response from daemon: network <id> not foundFailed to remove some resources from stack: <name>
When using docker network ls
, the network is indeed not removed, however, docker network rm <id>
always results in the following:
Error response from daemon: network <id> not found
What makes that even more strange is the fact that docker network inspect <id>
returns a normal output. The networks are always overlay
networks that are created with the compose files used to deploy our stack. Currently, we only have a single node in our Swarm.
Our current "workaround" is to restart Docker (which resolves the issue), but that is not a viable solution in a production environment. Leaving the swarm and joining it again does not resolve the issue either.
At first, we thought that this issue is related to Docker for Mac only (as we first encountered the issue on local machines), however, the same issue arises on Debian Stretch. In both cases, we use the latest Docker distribution available.
I would really appreciate any help!
Use the --network-add or --network-rm flags to add or remove a network for a service. You can use the short or long syntax discussed in the docker service create reference.
Deleting the "network not found" in docker. old containers are still using old network. Probably you removed networks but forgot to rm old containers. Just remove old containers, create your network and build again.
If you want to add a container to a network after the container is already running, use the docker network connect subcommand. You can connect multiple containers to the same network. Once connected, the containers can communicate using only another container’s IP address or name.
If you don’t specify the --driver option, the command automatically creates a bridge network for you. When you install Docker Engine it creates a bridge network automatically. This network corresponds to the docker0 bridge that Engine has traditionally relied on.
Docker Engine network plugins enable Engine deployments to be extended to support a wide range of networking technologies, such as VXLAN, IPVLAN, MACVLAN or something completely different. Network driver plugins are supported via the LibNetwork project.
If you are attempting to add a container to an existing network that no longer exists, then you can use docker-compose up --force-recreate
. I found this GitHub issues comment to be a helpful overview.
You can always use docker system prune -a
to get rid of the old network. This will not delete your volumes.
It will take longer to docker-compose up --build -d
the next time, but it will get you past your current problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With