{"id":"8d725274c1d09dbb","repo":"docker/cli","slug":"this-node-is-not-a-swarm-manager-use-docker-swar","errorCode":null,"errorMessage":"this node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again","messagePattern":"this node is not a swarm manager\\. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/deploy.go","lineNumber":107,"sourceCode":"\tif opts.detach && !flags.Changed(\"detach\") {\n\t\t_, _ = fmt.Fprintln(dockerCLI.Err(), \"Since --detach=false was not specified, tasks will be created in the background.\\n\"+\n\t\t\t\"In a future release, --detach=false will become the default.\")\n\t}\n\n\treturn deployCompose(ctx, dockerCLI, opts, cfg)\n}\n\n// checkDaemonIsSwarmManager does an Info API call to verify that the daemon is\n// a swarm manager. This is necessary because we must create networks before we\n// create services, but the API call for creating a network does not return a\n// proper status code when it can't create a network in the \"global\" scope.\nfunc checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error {\n\tres, err := dockerCli.Client().Info(ctx, client.InfoOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !res.Info.Swarm.ControlAvailable {\n\t\treturn errors.New(`this node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again`)\n\t}\n\treturn nil\n}\n\n// pruneServices removes services that are no longer referenced in the source\nfunc pruneServices(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, services map[string]struct{}) {\n\tapiClient := dockerCLI.Client()\n\n\toldServices, err := getStackServices(ctx, apiClient, namespace.Name())\n\tif err != nil {\n\t\t_, _ = fmt.Fprintln(dockerCLI.Err(), \"Failed to list services:\", err)\n\t}\n\n\ttoRemove := make([]swarm.Service, 0, len(oldServices.Items))\n\tfor _, service := range oldServices.Items {\n\t\tif _, exists := services[namespace.Descope(service.Spec.Name)]; !exists {\n\t\t\ttoRemove = append(toRemove, service)\n\t\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/stack/deploy.go#L89-L125","documentation":"Emitted by `docker stack deploy` before any resources are created. checkDaemonIsSwarmManager (deploy.go:101-110) calls the Info API and requires Swarm.ControlAvailable; the pre-check exists because network creation in the global scope does not return a proper status code when the daemon isn't a manager, so the CLI verifies manager status up front.","triggerScenarios":"Running `docker stack deploy` against a daemon where Info reports Swarm.ControlAvailable == false: swarm mode never initialized, the node is a worker, or the node left the swarm.","commonSituations":"Fresh Docker install where `docker swarm init` was never run; running stack deploy on a worker node or via a context/DOCKER_HOST pointing at a worker; CI runners with ephemeral daemons that lose swarm state; a manager that was demoted or lost quorum.","solutions":["On a single-node setup, run `docker swarm init` (add --advertise-addr <ip> if multiple interfaces) and retry the deploy","If this host should join an existing swarm, run the `docker swarm join --token ...` command from `docker swarm join-token manager|worker` on a manager","If it is a worker, run the deploy on a manager instead, or promote it with `docker node promote <node>` from a manager","Check `docker info --format '{{.Swarm.LocalNodeState}} {{.Swarm.ControlAvailable}}'` and verify DOCKER_HOST/context targets the intended node"],"exampleFix":"# before\ndocker stack deploy -c compose.yml mystack\n# this node is not a swarm manager...\n\n# after\ndocker swarm init\ndocker stack deploy -c compose.yml mystack","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["swarm","stack","deploy","swarm-manager","cluster"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}