docker/cli ยท error

could not fetch unlock key: %w

Error message

could not fetch unlock key: %w

What it means

Error "could not fetch unlock key: %w" thrown in docker/cli.

Source

Thrown at cli/command/swarm/init.go:129

	if err != nil {
		if strings.Contains(err.Error(), "could not choose an IP address to advertise") || strings.Contains(err.Error(), "could not find the system's IP address") {
			return fmt.Errorf("%w - specify one with --advertise-addr", err)
		}
		return err
	}

	_, _ = fmt.Fprintf(dockerCLI.Out(), "Swarm initialized: current node (%s) is now a manager.\n\n", res.NodeID)

	if err := printJoinCommand(ctx, dockerCLI, res.NodeID, true, false); err != nil {
		return err
	}

	_, _ = fmt.Fprintln(dockerCLI.Out(), "To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.")

	if opts.swarmOptions.autolock {
		resp, err := apiClient.SwarmGetUnlockKey(ctx)
		if err != nil {
			return fmt.Errorf("could not fetch unlock key: %w", err)
		}
		printUnlockCommand(dockerCLI.Out(), resp.Key)
	}

	return nil
}

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/swarm/init.go:129 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/83516f7ed1a4807e.json. Report an issue: GitHub.