How to connect a node to Docker Swarm
Jack Wallen walks through the steps to connect new nodes to Docker Swarm as a worker and manager to help manage larger Docker clusters.
Got a Docker Swarm up and running and need to add more nodes to it? You probably remember how the Docker Swarm initialization provided the join command. The connection token from the command can only be used once, so even if you copied the command to a file, it won’t work on a new node.
Fortunately, however, the Docker developers have made it possible to add new nodes to a Swarm at any time. This requires Docker Swarm to work with at least one control node and one new node to connect to. You can add as many nodes as you want and do so at any time.
You can join a node as a worker or manager. The difference is simple: manager nodes elect a leader to perform orchestration tasks, while worker nodes receive and execute tasks sent from manager nodes. You’ll probably connect to the node as a worker, but I’ll show you the commands for both.
First, let’s join a node as a worker. Log in to the Docker Swarm controller node and issue the command docker swarm join-token worker
. The output contains the docker swarm join command that you will run on the new worker node. If you need to create a new token, use the spin option, for example: docker swarm join-token --rotate worker
.
Now, if you want to connect to a node as a manager, the command is: docker swarm join-token manager
. To create a new connection token, you can use the spin option in the same way as the docker swarm join-token --rotate manager
.
After you run one of the commands on the new node, it joins Swarm as either a worker or a manager, and is ready to develop and manage a larger Docker cluster.
Subscribe to TechRepublic How to make the technique work on YouTube for Jack Wallen’s latest technology advice for business professionals.
Source: https://www.techrepublic.com/article/how-to-join-node-docker-swarm/