{"id":"ce690ffc93a4b385","repo":"docker/cli","slug":"network-prune-has-been-cancelled","errorCode":null,"errorMessage":"network prune has been cancelled","messagePattern":"network prune has been cancelled","errorType":"exception","errorClass":"cancelledErr","httpStatus":null,"severity":"info","filePath":"cli/command/network/prune.go","lineNumber":71,"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 custom networks not used by at least one container.\nAre you sure you want to continue?`\n\nfunc runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (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 \"\", err\n\t\t}\n\t\tif !r {\n\t\t\treturn \"\", cancelledErr{errors.New(\"network prune has been cancelled\")}\n\t\t}\n\t}\n\n\tres, err := dockerCli.Client().NetworkPrune(ctx, client.NetworkPruneOptions{\n\t\tFilters: pruneFilters,\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar out strings.Builder\n\tif len(res.Report.NetworksDeleted) > 0 {\n\t\tout.WriteString(\"Deleted Networks:\\n\")\n\t\tfor _, id := range res.Report.NetworksDeleted {\n\t\t\tout.WriteString(id + \"\\n\")\n\t\t}\n\t}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/network/prune.go#L53-L89","documentation":"Returned by `docker network prune` when the interactive confirmation prompt is answered with anything other than yes. It is wrapped in cancelledErr (implementing a Cancelled() marker) so the CLI can distinguish a deliberate user abort from a real failure; no networks are touched.","triggerScenarios":"Running `docker network prune` without --force and answering 'n' (or the prompt returning false) at the 'WARNING! This will remove all custom networks...' confirmation.","commonSituations":"Interactive use where the operator declines; CI/non-interactive scripts that run prune without -f and cannot answer the prompt, so it reads as declined or errors.","solutions":["Answer 'y' at the prompt if you intend to prune","Use `docker network prune --force` in scripts/automation to skip the confirmation","Treat this error as an intentional cancellation, not a failure, when handling exit status in wrappers"],"exampleFix":"# before\ndocker network prune\n# after (non-interactive)\ndocker network prune --force","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker","network","prune","user-cancelled"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}