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 \
172.31.46.109:2377
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:
SWMKEY-1-WuYH/IX284+lRcXuoVf38viIDK3HJEKY13MIHX+tTt8
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.