docker/cli · warning · cancelledErr
system prune has been cancelled
Error message
system prune has been cancelled
What it means
Returned by runPrune (cli/command/system/prune.go:87) wrapped in a cancelledErr when the user declines the confirmation prompt (and --force was not set). It is a controlled cancellation — cancelledErr implements the Cancelled() marker method — not a system failure; distinguish it from real prune errors.
Solutions
- Answer 'y' to confirm at the prompt.
- Use `--force`/`-f` to skip the prompt in scripts: `docker system prune -f`.
- Detect cancellation programmatically by checking for the `Cancelled()` method on the returned error.
Example fix
// before
docker system prune # -> types 'n' -> system prune has been cancelled
// after (scripts)
docker system prune --force
# or programmatically detect cancellation:
// var c interface{ Cancelled() }
// if errors.As(err, &c) { /* user cancelled, not a failure */ } Defensive patterns
Strategy: try-catch
Type guard
// Detect a user-initiated cancellation vs a real prune failure.
func isCancelled(err error) bool {
var c interface{ Cancelled() }
return errors.As(err, &c)
} Try / catch
err := runPrune(ctx, dockerCli, options)
if err != nil {
var c interface{ Cancelled() }
if errors.As(err, &c) {
// user declined the prompt — not a failure; exit 0 or log and continue
return nil
}
return err
} Prevention
- Pass --force in non-interactive/CI contexts to avoid the prompt.
- Treat cancelledErr (Cancelled()) as a soft cancel, not a hard failure.
- Confirm TTY availability before relying on interactive prompts in automation.
When it happens
Trigger: Running `docker system prune` interactively and answering 'n' (or anything non-affirmative) at the 'Are you sure you want to continue?' prompt; a non-interactive invocation where the input stream yields no confirmation.
Common situations: Cautious operator declines; a script forgot `--force` and the TTY/piped input doesn't confirm; CI harness that expects pruning but didn't pass -f.
Related errors
- network prune has been cancelled
- builder prune has been cancelled
- container prune has been cancelled
- containers prune has been cancelled
- every ip-range or gateway must have a corresponding subnet
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/b095329fb0aa9355.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/system/prune.go:87
Are you sure you want to continue?`
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) error {
// prune requires either force, or a user to confirm after prompting.
confirmed := options.force
// Validate the given options for each pruner and construct a confirmation-message.
confirmationMessage, err := dryRun(ctx, dockerCli, options)
if err != nil {
return err
}
if !confirmed {
var err error
confirmed, err = prompt.Confirm(ctx, dockerCli.In(), dockerCli.Out(), confirmationMessage)
if err != nil {
return err
}
if !confirmed {
return cancelledErr{errors.New("system prune has been cancelled")}
}
}
var spaceReclaimed uint64
for contentType, pruneFn := range pruner.List() {
switch contentType {
case pruner.TypeVolume:
if !options.pruneVolumes {
continue
}
case pruner.TypeContainer, pruner.TypeNetwork, pruner.TypeImage, pruner.TypeBuildCache:
// no special handling; keeping the "exhaustive" linter happy.
default:
// other pruners; no special handling; keeping the "exhaustive" linter happy.
}
spc, output, err := pruneFn(ctx, dockerCli, pruner.PruneOptions{
Confirmed: confirmed,View on GitHub (pinned to 4f84911bfe)