Skip to main content
In this walkthrough, you’ll learn how to enable Docker Swarm’s Auto-Lock feature to encrypt Raft logs and TLS keys on disk. With Auto-Lock enabled, any manager restarting or rejoining the cluster must provide the unlock key—adding a robust layer of security.

1. Enable Auto-Lock on Your Swarm

For an existing Swarm cluster, run:
This outputs a one-time unlock key, for example:
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

  1. Restart Docker on manager2:
  2. Attempt a Swarm command (should fail):
  3. Unlock the Swarm with your saved key:
  4. Confirm the node list again:
Congratulations! Manager 2 has rejoined securely with Auto-Lock enabled.

Watch Video