docker/cli · error
error: this node is not part of a swarm
Error message
error: this node is not part of a swarm
What it means
Thrown by runUnlock (cli/command/swarm/unlock.go:51) when an Info call reports LocalNodeState == Inactive, meaning this engine has never joined or initialized a swarm. There is nothing to unlock, so the command refuses rather than prompting for a key.
Solutions
- Initialize or join a swarm first: `docker swarm init` (manager) or `docker swarm join --token <t> <ip:2377>`.
- Confirm the node's swarm state with `docker info` (look for `Swarm: inactive`).
Example fix
// before (not in a swarm) docker swarm unlock # -> error: this node is not part of a swarm // after docker swarm init # or: docker swarm join --token <t> <ip:2377>
Defensive patterns
Strategy: validation
Validate before calling
res, err := apiClient.Info(ctx, client.InfoOptions{})
if err != nil { return err }
if res.Info.Swarm.LocalNodeState == swarm.LocalNodeStateInactive {
return errors.New("node is not in a swarm; init or join first")
} Prevention
- Check `docker info` swarm state before unlock operations.
- Automate swarm init/join in provisioning so nodes are never inert.
- Guard scripts against running on freshly-imaged nodes.
When it happens
Trigger: Running `docker swarm unlock` on a node that was never part of a swarm, or that left the swarm (`docker swarm leave`) and is now inactive.
Common situations: Wrong host; fresh install; swarm was dissolved/left; node reset to factory state.
Related errors
- error: swarm is not locked
- node ID not found in /info
- when using secret driver secret data must be empty
- error reading from STDIN: data is empty
- secret file is required
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/58c9687175ba0da1.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/swarm/unlock.go:51
DisableFlagsInUseLine: true,
}
return cmd
}
func runUnlock(ctx context.Context, dockerCLI command.Cli) error {
apiClient := dockerCLI.Client()
// First see if the node is actually part of a swarm, and if it is actually locked first.
// If it's in any other state than locked, don't ask for the key.
res, err := apiClient.Info(ctx, client.InfoOptions{})
if err != nil {
return err
}
switch res.Info.Swarm.LocalNodeState {
case swarm.LocalNodeStateInactive:
return errors.New("error: this node is not part of a swarm")
case swarm.LocalNodeStateLocked:
break
case swarm.LocalNodeStatePending, swarm.LocalNodeStateActive, swarm.LocalNodeStateError:
return errors.New("error: swarm is not locked")
}
key, err := readKey(dockerCLI.In(), "Enter unlock key: ")
if err != nil {
return err
}
_, err = apiClient.SwarmUnlock(ctx, client.SwarmUnlockOptions{
Key: key,
})
return err
}
func readKey(in *streams.In, prompt string) (string, error) {View on GitHub (pinned to 4f84911bfe)