1. Enable Auto-Lock on Your Swarm
For an existing Swarm cluster, run:To enable Auto-Lock during cluster creation, use:
2. Store the Unlock Key Securely
Save the key in a safe location. For demo purposes we’ll use/tmp/swarm-unlock.key. In production, consider a secrets manager or vault.
Losing this key means you cannot unlock your Swarm managers. Always back it up securely.
3. Quick Reference: Swarm Auto-Lock Commands
4. Verify Cluster Health on Manager 1
Even with Auto-Lock active, manager1 can query node status without unlocking:5. Test Auto-Lock on Manager 2
- Restart Docker on manager2:
- Attempt a Swarm command (should fail):
- Unlock the Swarm with your saved key:
- Confirm the node list again: