In this tutorial I will show how easy it is to create a Docker Swarm.
Precondition
- docker-machine installed
Instructions
# create a new cluster identifier $ docker-machine create -d virtualbox local $ eval "$(docker-machine env local)" # generate discovery token $ docker run --rm swarm create
Copy the resulting value for <TOKEN-ID>. The following commands will create a Swarm cluster.
# create swarm master $ docker-machine create -d virtualbox --swarm --swarm-discovery token://<TOKEN-ID> --swarm-master swarm-manager # create swarm nodes $ docker-machine create -d virtualbox --swarm --swarm-discovery token://<TOKEN-ID> swarm-node-01 $ docker-machine create -d virtualbox --swarm --swarm-discovery token://<TOKEN-ID> swarm-node-02 $ docker-machine create -d virtualbox --swarm --swarm-discovery token://<TOKEN-ID> swarm-node-03 # delete unused cluser identifier vm $ docker-machine rm local # pointing shell to swarm master $ eval $(docker-machine env --swarm swarm-manager) # show information $ docker-machine ls $ docker info