docker/cli · info · cancelledErr
network prune has been cancelled
Error message
network prune has been cancelled
What it means
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.
Source
Thrown at cli/command/network/prune.go:71
flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
flags.Var(&options.filter, "filter", `Provide filter values (e.g. "until=<timestamp>")`)
return cmd
}
const warning = `WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue?`
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, _ error) {
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
if !options.force {
r, err := prompt.Confirm(ctx, dockerCli.In(), dockerCli.Out(), warning)
if err != nil {
return "", err
}
if !r {
return "", cancelledErr{errors.New("network prune has been cancelled")}
}
}
res, err := dockerCli.Client().NetworkPrune(ctx, client.NetworkPruneOptions{
Filters: pruneFilters,
})
if err != nil {
return "", err
}
var out strings.Builder
if len(res.Report.NetworksDeleted) > 0 {
out.WriteString("Deleted Networks:\n")
for _, id := range res.Report.NetworksDeleted {
out.WriteString(id + "\n")
}
}
View on GitHub (pinned to e9452d6e78)
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
Example fix
# before docker network prune # after (non-interactive) docker network prune --force
When it happens
Trigger: Running `docker network prune` without --force and answering 'n' (or the prompt returning false) at the 'WARNING! This will remove all custom networks...' confirmation.
Common situations: 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.
Related errors
- builder prune has been cancelled
- container prune has been cancelled
- every ip-range or gateway must have a corresponding subnet
- multiple overlapping subnet configuration is not supported
- plugin upgrade has been cancelled
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/ce690ffc93a4b385.json.
Report an issue: GitHub.