Error response from daemon: network myapp not found

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.


in my case i had to:

docker system prune
systemctl restart docker.service

to make it work again...


Remove container (not Image) and then run again:

docker compose up

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.

Tags:

Docker