Jack Wallen shows you the steps to join new nodes to a Docker Swarm as a worker and manager to help you manage larger Docker clusters.
Do you have a working Docker Swarm and need to add more nodes to it? You probably remember how Docker Swarm initialization introduced you to the join command. The join token for this command can only be used once, so even if you copied this command to a file, it won’t work for a new node.
Fortunately, however, Docker developers have made it possible to join new nodes to a Swarm at any time. To do this, you must have a working Docker Swarm with at least one controller node and one new node to join. You can add as many nodes as needed and do so at any time.
You can join a node as a worker or a manager. The difference is simple: manager nodes elect a leader to perform orchestration tasks, while worker nodes receive and execute tasks that are dispatched from manager nodes. Most likely you’ll join the node as a worker, but I’ll show you the commands for both.
First, let’s join a node as a worker. Login to your Docker Swarm controller node and issue the command
docker swarm join-token worker. The output will include the docker swarm join command that you will run on the new worker node. If you need to generate a new token, use the rotation option as follows:
docker swarm join-token --rotate worker.
Now if you want to join a node as a manager, the command is
docker swarm join-token manager. To create a new join token, you can use the rotate option the same way with
docker swarm join-token --rotate manager.
Once you run one of these commands on your new node, it will join the Swarm as a worker or manager, and you’re ready to grow and manage a larger Docker cluster.
Subscribe to TechRepublic How to make the technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.