To create our swarm, we first need to instantiate it:
$ docker swarm init
Swarm initialized: current node (osb7tritzhtlux1o9unlu2vd0) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join
--token SWMTKN-1-4atg39hw64uagiqk3i6s3zlv5mforrzj0kk1aeae22tpsat2jj-2zn0ak0ldxo58d1q7347t4rd5
192.168.4.128:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
$ # Make sure that our node is operational
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
osb7tritzhtlux1o9unlu2vd0 * feather2 Ready Active Leader
We have created a swarm with that command and we are automatically enrolled as a manager node. If you take a look at the output, the command for adding worker nodes is just docker swarm join --token <token> <ip>, but we are interested in a single-node deployment for now, so we won't need to worry about it. Given that our manager node is also a worker node, we can just use it as-is to throw a few services on it.