View the current swarm unlock key
In this step, we will learn how to view the current swarm unlock key in a Docker Swarm. The swarm unlock key is used to unlock a Swarm after it has been restarted. This is a security measure to prevent unauthorized access to your Swarm.
First, we need to initialize a Docker Swarm. We will use the docker swarm init
command. This command will initialize a new Swarm and make the current node a manager node.
docker swarm init
You should see output similar to this, indicating that the Swarm has been initialized:
Swarm initialized: current node (xxxxxxxxxxxx) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.1.100:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
Now that we have a Swarm initialized, we can view the current swarm unlock key using the docker swarm unlock-key
command.
docker swarm unlock-key
This command will output the current swarm unlock key. It will look like a long string of characters.
Swarm unlock key: SWMKEY-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keep this key secure, as it is required to unlock your Swarm after a restart.