Difference between docker machine with swarm options and running docker swarm init and join

I was trying to set up a cluster with docker swarm. However, I am a bit confused about how is docker-machine with swarm options different from initialising a swarm manager on one host and joining as workers from other hosts.

Here is an example for my question:
docker-machine with swarm options

docker-machine create --driver virtualbox --swarm --swarm-master --virtualbox-hostonly-cidr “10.0.0.1/24” node1
docker-machine create --driver virtualbox --swarm --swarm-discovery “token://…” --virtualbox-hostonly-cidr “10.0.0.1/24” node2
docker-machine create --driver virtualbox --swarm --swarm-discovery “token://…” --virtualbox-hostonly-cidr “10.0.0.1/24” node3

join a manager node as worker nodes

docker-machine create --driver virtualbox --virtualbox-hostonly-cidr “10.0.0.1/24” node1
docker-machine create --driver virtualbox --virtualbox-hostonly-cidr “10.0.0.1/24” node2
docker-machine create --driver virtualbox --virtualbox-hostonly-cidr “10.0.0.1/24” node3

eval $(docker-machine env node1)
docker swarm init
eval $(docker-machine env node2)
docker swarm join --token <node1_IP>
eval $(docker-machine env node3)
docker swarm join --token <node1_IP>

1 Like