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

  1. Answer 'y' at the prompt if you intend to prune
  2. Use `docker network prune --force` in scripts/automation to skip the confirmation
  3. 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


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/ce690ffc93a4b385.json. Report an issue: GitHub.