Docker Community Forums

Share and learn in the Docker community.

How to check if a swarm network exists from a worker node

Hello, we are writing a bash script to automate the provisioning of an application. One of the tasks that we need to do is to check if a network already exists. we do this using the

docker network ls

command but this command does not list the swarm networks when run on a worker node. How can a worker node determine if a swarm exists?

$ docker version
Client:
 Version:           18.06.2-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        6d37f41
 Built:             Sun Feb 10 03:46:03 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.2-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       6d37f41
  Built:            Sun Feb 10 03:48:29 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Attachable overlay network is not available to Swarm worker nodes · Issue #36197 · moby/moby · GitHub says:

unfortunately for how it is today the logic and for security reasons, workers node are not aware of the resources allocated, only managers do. The idea is that worker nodes received only what is currently needed for handling the tasks assigned

but this is really problematic. is there any update since then? we would like to know if a swarm network exists from a worker node.