{"id":"ff4968474657e937","repo":"docker/cli","slug":"container-prune-has-been-cancelled","errorCode":null,"errorMessage":"container prune has been cancelled","messagePattern":"container prune has been cancelled","errorType":"exception","errorClass":"cancelledErr","httpStatus":null,"severity":"info","filePath":"cli/command/container/prune.go","lineNumber":74,"sourceCode":"\tflags.BoolVarP(&options.force, \"force\", \"f\", false, \"Do not prompt for confirmation\")\n\tflags.Var(&options.filter, \"filter\", `Provide filter values (e.g. \"until=<timestamp>\")`)\n\n\treturn cmd\n}\n\nconst warning = `WARNING! This will remove all stopped containers.\nAre you sure you want to continue?`\n\nfunc runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, _ error) {\n\tpruneFilters := command.PruneFilters(dockerCli, options.filter.Value())\n\n\tif !options.force {\n\t\tr, err := prompt.Confirm(ctx, dockerCli.In(), dockerCli.Out(), warning)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tif !r {\n\t\t\treturn 0, \"\", cancelledErr{errors.New(\"container prune has been cancelled\")}\n\t\t}\n\t}\n\n\tres, err := dockerCli.Client().ContainerPrune(ctx, client.ContainerPruneOptions{\n\t\tFilters: pruneFilters,\n\t})\n\tif err != nil {\n\t\treturn 0, \"\", err\n\t}\n\n\tvar out strings.Builder\n\tif len(res.Report.ContainersDeleted) > 0 {\n\t\tout.WriteString(\"Deleted Containers:\\n\")\n\t\tfor _, id := range res.Report.ContainersDeleted {\n\t\t\tout.WriteString(id + \"\\n\")\n\t\t}\n\t\tspaceReclaimed = res.Report.SpaceReclaimed\n\t}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/prune.go#L56-L92","documentation":"Returned by runPrune in cli/command/container/prune.go when the interactive confirmation prompt for `docker container prune` is answered negatively. It is wrapped in cancelledErr (implementing a Cancelled() marker) so the CLI can distinguish a user-declined operation from a real failure; nothing was deleted.","triggerScenarios":"Running `docker container prune` without --force and answering 'n' (or anything not affirmative) at the 'WARNING! This will remove all stopped containers' prompt; prompt.Confirm returning false, e.g. also when stdin is closed/non-interactive so the confirmation defaults to no.","commonSituations":"Running the command in CI, cron, or a script where no TTY/stdin is available so confirmation cannot be given; deliberately backing out after reading the warning; wrappers that pipe empty input into the command.","solutions":["If the cancellation was unintended (scripts/CI), pass --force / -f to skip the confirmation prompt: docker container prune -f","If run interactively, answer 'y' at the prompt to proceed","Add --filter (e.g. until=24h) to narrow what would be pruned before confirming"],"exampleFix":"# before (hangs or cancels in CI)\ndocker container prune\n# after\ndocker container prune --force --filter \"until=24h\"","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","prune","user-cancelled"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}