{"record":{"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/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/stack/deploy.go#L89-L125","documentation":"Thrown by checkDaemonIsSwarmManager (cli/command/stack/deploy.go:107) after an Info API call. Stack deploy must create swarm-scoped networks and services, which only a manager can do; if `res.Info.Swarm.ControlAvailable` is false (worker or non-swarm node), the operation is aborted before any resource is created.","triggerScenarios":"Running `docker stack deploy` on a swarm worker node, or on a standalone engine that is not part of any swarm. The Info call succeeds but ControlAvailable is false.","commonSituations":"SSH'd into the wrong host (a worker); CI targets a worker by misconfiguration; the swarm was dissolved/rotated and this node lost manager status; load-balancer routed the Docker socket to a worker.","solutions":["Run the deploy from a manager node.","Initialize a new swarm: `docker swarm init`.","Join this node as a manager: `docker swarm join --token <manager-token> <manager-ip:2377>`.","Verify with `docker info` that `Swarm: active` and `Is Manager: true`."],"exampleFix":"// before (on a worker)\ndocker stack deploy -c compose.yml mystack\n\n// after\n# on a manager node, or first:\ndocker swarm init   # or join as manager\ndocker stack deploy -c compose.yml mystack","handlingStrategy":"validation","validationCode":"// Verify manager status before stack operations.\nres, err := apiClient.Info(ctx, client.InfoOptions{})\nif err != nil { return err }\nif !res.Info.Swarm.ControlAvailable {\n\treturn errors.New(\"target node is not a swarm manager; aborting deploy\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin deploy commands to a known manager endpoint.","In CI, assert `docker info --format '{{.Swarm.ControlAvailable}}'` is true first.","Keep a list of manager node addresses and fail fast if unreachable."],"tags":["docker","swarm","stack","deploy","manager","rbac"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}