Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (2.3k points)
How can I autolock the swarm when it gets initialized. Is there a docker swarm command for it?

1 Answer

0 votes
by (6.9k points)
edited by

Yes there is, 

$ docker swarm init --autolock

You should get an output like this once you type it in:

Swarm initialized: current node (k1q27tfyx9rncpixhk69sa61v) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-1-0j52ln6hxjpxk2wgk917abcnxywj3xed0y8vi1e5m9t3uttrtu-7bnxvvlz2mrcpfonjuztmtts9 \

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

 Store the key you get in the end in a safe place, You will need it to unlock the swarm when you restart it.

Unlock the swarm using the below command:

$ docker swarm unlock

Please enter unlock key:

You can also enable disable or enable the  auto lock using these commands:

$ docker swarm update --autolock=false
$ docker swarm update --autolock=true

 Hope this helps you :)

Docker can be tough to learn without any supervision, you can be stuck in you own bubble and not follow all the best practices, so if you want to get trained by professionals check out docker training course.

Browse Categories