moby: Docker stack Error response from daemon: network *_default not found

Description

Docker is unable to deploy a simple stack, reporting “Error response from daemon: network myapp_default not found”

Steps to reproduce the issue:

  1. Create overlay attachable network mynet
$docker network create --attachable --driver overlay mynet
kc9u8lgi1yugpudo5qk6o2g58
$docker network inspect mynet
[
    {
        "Name": "mynet",
        "Id": "kc9u8lgi1yugpudo5qk6o2g58",
        "Created": "0001-01-01T00:00:00Z",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": []
        },
        "Internal": false,
        "Attachable": true,
        "Containers": null,
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4098"
        },
        "Labels": null
    }
]
  1. Write stack.yml compose-file
$cat stack.yml
version: "3"
networks:
  default:
    external:
      name: mynet
services:
  elasticsearch:
    command: "elasticsearch -E cluster.name=myapp -E node.name=elasticsearch -E discovery.zen.ping.unicast.hosts=elasticsearch"
    #hostname: "{{.Service.Name}}-{{.Task.Slot}}"
    image: "elasticsearch:5.2.1"
    #ulimits:
    #  memlock: -1
    #  nofile: 65536
    #  nproc: 2048
  1. Run docker stack deploy command
$docker stack deploy --compose-file stack.yml myapp
Creating service myapp_elasticsearch
Error response from daemon: network myapp_default not found

Describe the results you received:

Creating service myapp_elasticsearch Error response from daemon: network myapp_default not found

Describe the results you expected:

A simple elasticsearch stack being deployed

Output of docker version:

Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 7
 Running: 6
 Paused: 0
 Stopped: 1
Images: 42
Server Version: 1.13.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 116
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: active
 NodeID: ph56dmuj9xyp7v0mxngpi4wmg
 Is Manager: true
 ClusterID: jmdwt0h7bwcobihnfignepzwr
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: 155.54.212.5
 Manager Addresses:
  155.54.212.5:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-21-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 31.4 GiB
Name: computer
ID: E4N3:47NS:3QGR:EWSK:L4ZR:RWXL:JJXE:U53F:4NIU:N6XK:6OVD:WY4C
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 22 (3 by maintainers)

Most upvoted comments

I’ve had this issue too when removing a stack, with docker stack rm, the network lingers for about 10 seconds before it’s finally removed. So, if I call docker stack deploy, with the same stack name that I just removed, in that timeframe I get the above error too.

So restarting each docker daemon in the swarm helped:

sudo systemctl stop docker
sudo systemctl start docker

@w7089, thank you, your answer helped to me. Just want to point that systemctl have command restart, so

sudo systemctl restart docker

is enough 😃

Having the same issue with 17.10.0-ce Another issue was that some containers in output of:

docker ps -a

were in status:

Removal In Progress

So restarting each docker daemon in the swarm helped:

sudo systemctl stop docker
sudo systemctl start docker

Today I’ve got same issue. I had stack deployed on node1 (leader) and I was logged in on node3 (reacheable, but not actually leader). Then I called docker stack rm on node3 and tried to create stack on node1 again - and got same error. I’ve tried several times - nothing happens. And now I see:

on node3:

# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
27ed4ce9de56        bridge              bridge              local
617cf866d5bd        docker_gwbridge     bridge              local
3db70865c2ac        host                host                local
s3v2c7xmavsx        ingress             overlay             swarm
3ba25f9b4a70        none                null                local

on node1:

# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
slcw3alrpqtu        mystack_default    overlay             swarm
ccef8f87d4ab        bridge              bridge              local
86aae063b4c6        docker_gwbridge     bridge              local
3f70609d196c        host                host                local
s3v2c7xmavsx        ingress             overlay             swarm
b5b9248ca12b        none                null                local

and I can’t remove this network from node3:

# docker network rm mystack_default
Error response from daemon: network mystack_default not found

Any idea on the root cause of this? systemctl restart docker isn’t really a scalable solution.

So restarting each docker daemon in the swarm helped:

sudo systemctl stop docker
sudo systemctl start docker

@w7089, thank you, your answer helped to me. Just want to point that systemctl have command restart, so

sudo systemctl restart docker

is enough 😃

Thank you @w7089 & @romash1408 it helps me a lot.

I encounter this error with docker version 17.09.0-ce with a really simple stack deploy. The deploy not even declares network.

"starting container failed: No such network: logspout_default"
# docker network ls
NETWORK ID          NAME                    DRIVER              SCOPE
ff549dece2ca        bridge                  bridge              local
0e5d3fff5cad        docker_gwbridge         bridge              local

... 7 other local scope network

a87e9c85fcef        host                    host                local
6f8558ifs981        ingress                 overlay             swarm
sp6jai4grfrt        logspout_default        overlay             swarm
c1a69addad32        none                    null                local

Actually typing that up got me thinking and I think I can reliably reproduce it. If I delete the stack with stack rm and then run a docker-compose run command which creates the networks. Later on when I go to create the stack it has an error because it can’t create the network(s) since some already exist with the same name.

The issue is caused by attempting to start the stack before the old network has finished removing, you can work around this by explicitly polling and waiting for the network to be removed: https://github.com/moby/moby/issues/29293#issuecomment-318852549