简体   繁体   中英

Overlay network on Swarm Mode without Docker Machine

I currently have three hosts ( docker1 , docker2 and docker3 ) which I have not set up using Docker Machine, each one running the v1.12-rc4 Docker daemon.

I run docker swarm init on docker1 , which in turn prints a docker swarm join command which I run on both docker2 and docker3 . At that point, running docker info on each host contains the Swarm: active line.

It is at this point that the behavior seems to differ from what I used to get with the standalone Swarm container. Especially, running docker network ls will only show me the networks on the local host, and when trying to create an overlay network, it does not seem like worker nodes are aware of it ( ie it does not show up on their docker network ls .)

I feel like I have missed out on some important information relating to the workings of the Swarm Mode as opposed to the Swarm container.

What is the correct way of setting up such a cluster without Docker Machine on Docker 1.12 while getting the overlay network feature?

I too thought this was an issue when I first started using it.

This works a little differently in 1.12rc4 - when you deploy a container to your swarm with that network attached to it, it should then create the network on the other nodes as well.

Hope this helps!

Issue

You are using the docker command (used to communicate with your localhost Docker daemon ) and not the " swarm " command (used to communicate with the Swarm master).

Solution

It depends on the command you used to start Swarm. A full step-by-step tutorial (including details on how to deploy an overlay network) is detailled on this answer . I'm sure that reading this will help you ;)

With a network scope of swarm, the network is only propagated to worker nodes on an as-needed basis. If you create a service using that network, and it gets scheduled on that worker node, the network will show up in the docker network ls .

With the now-upcoming 1.13 release, you can get a network that has similar behavior to the non-swarm networks by doing docker network create --attachable ... . That network will be valid for both services and normal containers, and will be available to all members of the cluster. As of 1.13.0-rc2, those don't seem to show up in the output of docker network ls .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM