Docker Community Forums

Share and learn in the Docker community.

Docker Swarm Networking


(Prageethw) #1

Hi, Guys,

Is it possible to create multiple SDNs and connect a service to all of them (to networks of more than 2)?
for example, scenario 1 demo service started attaching 2 networks and in scenario 2 same service attached to 3 networks.

scenario 1

docker network create --driver overlay demo-db
docker network create --driver overlay demo
docker network create --driver overlay proxy

docker service create --name demo-db
–network demo-db
mongo:3.2.10

docker service create --name demo
-e DB=demo-db
–network demo
–network demo-db
demo:1.0

docker service create --name proxy
-p 80:80
-p 443:443
-p 8080:8080
–network proxy
–network demo
-e MODE=swarm
proxy

docker service ls

ID NAME MODE REPLICAS IMAGE PORTS
cl5d7ryscz4f demo replicated 1/1
pm9kj8fsi4kt demo-db replicated 1/1
y3ie75hbcytb proxy replicated 1/1

scenario 2

docker service create --name demo-db
–network demo-db
mongo:3.2.10

docker service create --name demo
-e DB=demo-db
–network demo
–network demo-db
–network proxy
demo:1.0

docker service create --name proxy
-p 80:80
-p 443:443
-p 8080:8080
–network proxy
-e MODE=swarm
proxy

docker service ps demo

ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
asq865sqiarf demo.1 demo:1.0 node-3 Running Starting 7 seconds ago
zpxw67ojy0r8 demo.1 demo:1.0 node-3 Shutdown Failed about a minute ago “task: non-zero exit (2)”

Question:

is it as designed that docker service cannot attach to network more than 2 or is it a bug in docker swarm?