Quick How-to to set up Swarm cluster

1.Define a file hosts with the entries below, where : is the IP address of the node manager, and and are simple nodes.

# Hosts
node1 ansible_host=
node2 ansible_host=
node3 ansible_host=


2.On node manager ( run :

$ docker swarm init 3. Run the docker swarm join command on the rest of nodes, using ansible

$ ansible swarm:’!′ -m shell -a ‘docker swarm join –token SWMTKN-1-32c9u5o0y7gbp3zg8wlvkacbcz0jcwnfgzyhitn5xk8v3gi7s5-2pyej0kduwv6kmx7ynjjvxnhl′

The token WMTKN-1-32c9u5o0y7gbp3zg8wlvkacbcz0jcwnfgzyhitn5xk8v3gi7s5-2pyej0kduwv6kmx7ynjjvxnhl should depends on the return of the command : dockers swarm init.

4.Open 2377 TCP port on your firewall if you have one activated.

$ ufw allow 2377/tcp

5.Create the service :

$ docker service create –name hello-world –replicas 3 -p 80:80 dockercloud/hello-world