Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Network not Found

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!

like image 799
borchero Avatar asked Nov 17 '18 03:11

borchero


People also ask

What is the Docker command to add a network to a service?

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.

How to fix Network not found in Docker?

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.

How do I add a docker container to a network?

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.

What happens if I don't specify the--driver option in Docker?

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.

What are network plugins for the Docker engine?

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.


2 Answers

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.

like image 159
Nick Beaird Avatar answered Sep 22 '22 14:09

Nick Beaird


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.

like image 31
fcnorman Avatar answered Sep 23 '22 14:09

fcnorman