Since all the functionality to set up a Docker Swarm cluster is already included in the Docker installation, this is actually a really easy thing to do. Let's see what commands we have available to us:
$ docker swarm
<snip>
Commands:
init Initialize a swarm
join Join a swarm as a node and/or manager
join-token Manage join tokens
leave Leave the swarm
unlock Unlock swarm
unlock-key Manage the unlock key
update Update the swarm
A few things to note here--some more apparent than others:
- You create a swarm with docker swarm init
- You join a cluster with docker swarm join and the machine can be a worker node, a manager node, or both
- Authentication is managed using tokens (unique strings that need to match)
- If something happens to a manager node, such as a restart or power cycle, and you have set up auto-locking of the swarm, you will need an unlock key to unlock the TLS keys
So far, so good, so let's see whether we can set up a swarm with our machine serving both as a manager and a worker to see how this works.