{"record":{"id":"d91f0a32b86a45a0","repo":"docker/cli","slug":"nothing-found-in-stack-s","errorCode":null,"errorMessage":"nothing found in stack: %s","messagePattern":"nothing found in stack: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli/command/stack/ps.go","lineNumber":64,"sourceCode":"\tflags.BoolVar(&opts.noResolve, \"no-resolve\", false, \"Do not map IDs to Names\")\n\tflags.VarP(&opts.filter, \"filter\", \"f\", \"Filter output based on conditions provided\")\n\tflags.BoolVarP(&opts.quiet, \"quiet\", \"q\", false, \"Only display task IDs\")\n\tflags.StringVar(&opts.format, \"format\", \"\", flagsHelper.FormatHelp)\n\treturn cmd\n}\n\n// runPS is the swarm implementation of docker stack ps\nfunc runPS(ctx context.Context, dockerCLI command.Cli, opts psOptions) error {\n\tapiClient := dockerCLI.Client()\n\tres, err := apiClient.TaskList(ctx, client.TaskListOptions{\n\t\tFilters: getStackFilterFromOpt(opts.namespace, opts.filter),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(res.Items) == 0 {\n\t\treturn fmt.Errorf(\"nothing found in stack: %s\", opts.namespace)\n\t}\n\n\tif opts.format == \"\" {\n\t\topts.format = task.DefaultFormat(dockerCLI.ConfigFile(), opts.quiet)\n\t}\n\n\treturn task.Print(ctx, dockerCLI, res, idresolver.New(apiClient, opts.noResolve), !opts.noTrunc, opts.quiet, opts.format)\n}\n","sourceCodeStart":46,"sourceCodeEnd":73,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/stack/ps.go#L46-L73","documentation":"Returned by runPS when `docker stack ps <stack>` finds zero tasks. The TaskList query (filtered by the stack namespace label) returns no items, indicating either the stack name is wrong, the stack has no services/tasks, or the tasks were already cleaned up.","triggerScenarios":"Running `docker stack ps <name>` where no tasks carry the com.docker.stack.namespace=<name> label. The check at ps.go:63 returns this error (not a daemon failure, but an empty result).","commonSituations":"Typo in the stack name; querying a stack that was never deployed or already removed; the stack's services have no running tasks (all removed); querying too early before tasks are scheduled.","solutions":["Confirm the stack name with `docker stack ls`.","Verify the stack has services: `docker stack services <name>`.","If the stack was removed, there are no tasks to list by design.","Check spelling and that you're targeting the right Swarm/manager."],"exampleFix":"// before\ndocker stack ps mystak   # typo\n// after\ndocker stack ls            # find the real name\ndocker stack ps mystack","handlingStrategy":"validation","validationCode":"// Pre-check: confirm a stack has tasks before listing\nsvcs, err := getStackServices(ctx, c, namespace)\nif err != nil { return err }\nif len(svcs.Items) == 0 {\n    return fmt.Errorf(\"no services in stack %q; nothing to list\", namespace)\n}","typeGuard":null,"tryCatchPattern":"err := runPS(ctx, cli, opts)\nif err != nil && strings.Contains(err.Error(), \"nothing found in stack\") {\n    // treat as non-fatal empty result, not a hard error\n    return nil\n}","preventionTips":["Verify the stack name with `docker stack ls` before `docker stack ps`.","Treat 'nothing found' as an expected empty state in automation."],"tags":["docker","stack","ps","tasks","not-found","swarm"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}