{"id":"03b57629a0addacc","repo":"docker/cli","slug":"volume-prune-has-been-cancelled","errorCode":null,"errorMessage":"volume prune has been cancelled","messagePattern":"volume prune has been cancelled","errorType":"exception","errorClass":"cancelledErr","httpStatus":null,"severity":"info","filePath":"cli/command/volume/prune.go","lineNumber":89,"sourceCode":"\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\twarning := unusedVolumesWarning\n\tif options.all {\n\t\tif _, ok := pruneFilters[\"all\"]; ok {\n\t\t\treturn 0, \"\", invalidParamErr{errors.New(\"conflicting options: cannot specify both --all and --filter all=1\")}\n\t\t}\n\t\tpruneFilters.Add(\"all\", \"true\")\n\t\twarning = allVolumesWarning\n\t}\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(\"volume prune has been cancelled\")}\n\t\t}\n\t}\n\n\tres, err := dockerCli.Client().VolumePrune(ctx, client.VolumePruneOptions{\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.VolumesDeleted) > 0 {\n\t\tout.WriteString(\"Deleted Volumes:\\n\")\n\t\tfor _, id := range res.Report.VolumesDeleted {\n\t\t\tout.WriteString(id + \"\\n\")\n\t\t}\n\t\tspaceReclaimed = res.Report.SpaceReclaimed\n\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/volume/prune.go#L71-L107","documentation":"Returned by docker CLI's `docker volume prune` (runPrune in cli/command/volume/prune.go) when the interactive confirmation prompt is answered with anything other than yes. The error is wrapped in cancelledErr, which implements a Cancelled() marker interface so the CLI can exit without treating it as a hard failure. It exists to make user-declined prunes distinguishable from real errors.","triggerScenarios":"Running `docker volume prune` (or `docker volume prune --all`) without the -f/--force flag and answering 'n' (or anything non-affirmative) at the 'Are you sure you want to continue? [y/N]' prompt; also triggered if stdin is closed/non-interactive so the prompt defaults to No.","commonSituations":"Scripts or CI pipelines invoking `docker volume prune` without -f, where there is no TTY and the prompt auto-declines; users pressing Enter at the prompt (default is No); wrappers piping empty stdin into the command.","solutions":["Pass -f/--force to skip the confirmation prompt in scripts and CI: `docker volume prune -f`","If interactive, answer 'y' at the prompt to proceed","Treat this exit as a deliberate cancellation, not a failure, when parsing CLI output"],"exampleFix":"# before (hangs or cancels in CI)\ndocker volume prune\n# after\ndocker volume prune -f","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","volume","prune","user-cancelled"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}