简体   繁体   中英

Should Swarm Master Join As Node in a Single Node Cluster?

We are building a small cluster, and a (strange) requirement is to setup everything in one machine, to which other machines can join in the future.

I set up consul with:

docker run -d -p 8500:8500 --name=consul progrium/consul -server -bootstrap

and the master with:

docker run -d -p 4000:4000 swarm manage -H :4000 --advertise <ip_here>:4000 consul://<ip_here>:8500

where docker is run with:

sudo docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

and docker -H :4000 info lists the Nodes as 0 at this stage, where I cannot run any images with docker -H :4000 run <image> because No healthy node available in the cluster.

When I join the master node to the cluster with:

docker run -d swarm join --advertise=<ip_here>:2375 consul://<ip_here>:8500

Then docker -H :4000 info lists the Nodes as 1, and I can run containers.

Please note that <ip_here> refers all to the same ip of the machine.

Is this the intended behaviour? If not, what am I doing wrong?

After seeing Docker Machine's way of creating a Swarm cluster, as well as using Swarm that is integrated into Docker v1.12.0, I wanted to post an update. Swarm master does join Swarm cluster, by running two containers, an agent and a master.

As for me, I use the Swarm Master as the Consul server. This answer may help you. Then, to answer, the Swarm Master does not join in as a single node cluster.

You can't deploy Swarm on a single node. That's not its use and cannot work that way. Swarm turns a pool of Docker hosts into a single, virtual Docker host , so if the pool of Docker hosts contains zero hosts... There is no Docker Agent to host container.

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