{"id":"f4193f26cb033b3c","repo":"docker/cli","slug":"containers-prune-has-been-cancelled","errorCode":null,"errorMessage":"containers prune has been cancelled","messagePattern":"containers prune has been cancelled","errorType":"exception","errorClass":"cancelledErr","httpStatus":null,"severity":"info","filePath":"cli/command/container/prune.go","lineNumber":107,"sourceCode":"\t\t\tout.WriteString(id + \"\\n\")\n\t\t}\n\t\tspaceReclaimed = res.Report.SpaceReclaimed\n\t}\n\n\treturn spaceReclaimed, out.String(), nil\n}\n\ntype cancelledErr struct{ error }\n\nfunc (cancelledErr) Cancelled() {}\n\n// pruneFn calls the Container Prune API for use in \"docker system prune\",\n// and returns the amount of space reclaimed and a detailed output string.\nfunc pruneFn(ctx context.Context, dockerCLI command.Cli, options pruner.PruneOptions) (uint64, string, error) {\n\tif !options.Confirmed {\n\t\t// Dry-run: perform validation and produce confirmation before pruning.\n\t\tconfirmMsg := \"all stopped containers\"\n\t\treturn 0, confirmMsg, cancelledErr{errors.New(\"containers prune has been cancelled\")}\n\t}\n\treturn runPrune(ctx, dockerCLI, pruneOptions{\n\t\tforce:  true,\n\t\tfilter: options.Filter,\n\t})\n}\n","sourceCodeStart":89,"sourceCodeEnd":114,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/prune.go#L89-L114","documentation":"Returned by pruneFn in cli/command/container/prune.go, the container pruner registered with `docker system prune`. When the shared pruner framework calls it with options.Confirmed=false it acts as a dry-run: it returns the confirmation message ('all stopped containers') plus this cancelledErr sentinel so the system-prune orchestrator knows this pruner needs confirmation and has not run yet. It signals control flow, not a failure.","triggerScenarios":"`docker system prune` invoking the container pruneFn before the user has confirmed the aggregate prompt (options.Confirmed=false); declining the `docker system prune` confirmation so the container-prune stage is reported as cancelled.","commonSituations":"Seen when a user declines the `docker system prune` prompt, or in non-interactive environments where the prompt cannot be answered; occasionally surfaces in logs of tooling that wraps system prune without --force.","solutions":["Confirm the `docker system prune` prompt with 'y', or pass --force to skip confirmation entirely","If only stopped containers should be removed, run `docker container prune -f` directly","Treat this error as a cancellation sentinel (it implements a Cancelled() method), not a daemon failure — no cleanup occurred"],"exampleFix":"# before\ndocker system prune   # declined at prompt -> containers prune has been cancelled\n# after\ndocker system prune --force","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","system-prune","user-cancelled"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}