'Error response from daemon: network myapp not found
I am trying to create a container in a multihost network but while creating I am getting this error:
Error response from daemon: network myapp not found
Here myapp
is the name of overlay network which i have created. The command I am using is:
sudo docker run --rm -it --name=test_cont --net=myapp ubuntu bash
Solution 1:[1]
Docker networks are scoped for different access. Your myapp
network is an overlay network scoped to the swarm.
That means you can only use it at swarm level - docker service create --network myapp
will work fine, because services are at swarm level too.
You can start a container with docker run
on a swarm, but it will only run locally on the node where you run the command on, so it can't see swarm networks.
Solution 2:[2]
I started getting this error after doing a docker system prune
.
docker network ls
showed my network:
NETWORK ID NAME DRIVER SCOPE
pgl0gb0mbwql myapp overlay swarm
But deploying the stack would give error like:
failed to create service myapp_database: Error response from daemon: network myapp not found
Then I asked myself the most important debugging question there is: Have you tried turning it off and on again?
I restarted my docker daemon and the network was deleted for real. I was then able to re-create it and everything started working again.
Solution 3:[3]
Remove container (not Image) and then run again:
docker compose up
Solution 4:[4]
In my case, it did not delete the network even though it was in swarm mode, but if I created it again, it threw an error because there was already a network with that name. I had to restart the docker service, these were the steps:
docker network rm myapp #launch the error that the network did not exist
sudo systemctl restart docker.service #restart the docker service
docker network ls # not shows network.
Solution 5:[5]
Suppose that you connect myapp_net network to app_container then:
- docker network disconnect -f myapp_net app_container # Force disconnect
- docker network create myapp_net # Create docker network again
- docker network connect myapp_net app_container # Connect docker network again
It could resolve your problem.
Solution 6:[6]
In my case error was because of naming issue, recheck your network name in docker and give the same in your command.
steps I followed: (for windows)
- stop all the docker service
docker compose down
- close docker GUI and restart the docker
go to taskbar and click on show hidden icons --> right click it --> docker restart.
open terminal and go to the directory where the docker file is present (.yml)
run all the docker services using the cmd :
docker compose up
- open new terminal and run : check the network name
docker network ls
- copy the name and paste it in your network name section in your command.
docker run --tty --network < here your network name > confluentinc/cp-kafkacat kafkacat -b kafka: -C -s key=s -s value=avro -r http://schema-reg: -t postgres.public.shipments
Solution 7:[7]
in my case i had to:
docker system prune
systemctl restart docker.service
to make it work again...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Elton Stoneman |
Solution 2 | bohendo |
Solution 3 | alphaplus |
Solution 4 | Jaime Roman |
Solution 5 | user16605115 |
Solution 6 | |
Solution 7 | womd |