View the worker join token
In this step, we will learn how to view the join token for a worker node in a Docker Swarm. The join token is a secret that allows a new node to join the swarm as a worker.
First, you need to initialize a Docker Swarm if you haven't already. You can do this by running the following command:
docker swarm init
This command will make the current node a manager node and initialize the swarm. The output will include the command to join the swarm as a worker.
To view the worker join token, you can use the docker swarm join-token worker
command.
docker swarm join-token worker
This command will display the join token for worker nodes and the command to join the swarm as a worker. The output will look similar to this:
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.1.100:2377
The string after --token
is the worker join token. You would use this token on a different machine to join the swarm as a worker.