docker/cli · info · cancelledErr
container prune has been cancelled
Error message
container prune has been cancelled
What it means
Returned by runPrune in cli/command/container/prune.go when the interactive confirmation prompt for `docker container prune` is answered negatively. It is wrapped in cancelledErr (implementing a Cancelled() marker) so the CLI can distinguish a user-declined operation from a real failure; nothing was deleted.
Source
Thrown at cli/command/container/prune.go:74
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 stopped containers.
Are you sure you want to continue?`
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, 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 0, "", err
}
if !r {
return 0, "", cancelledErr{errors.New("container prune has been cancelled")}
}
}
res, err := dockerCli.Client().ContainerPrune(ctx, client.ContainerPruneOptions{
Filters: pruneFilters,
})
if err != nil {
return 0, "", err
}
var out strings.Builder
if len(res.Report.ContainersDeleted) > 0 {
out.WriteString("Deleted Containers:\n")
for _, id := range res.Report.ContainersDeleted {
out.WriteString(id + "\n")
}
spaceReclaimed = res.Report.SpaceReclaimed
}View on GitHub (pinned to e9452d6e78)
Solutions
- If the cancellation was unintended (scripts/CI), pass --force / -f to skip the confirmation prompt: docker container prune -f
- If run interactively, answer 'y' at the prompt to proceed
- Add --filter (e.g. until=24h) to narrow what would be pruned before confirming
Example fix
# before (hangs or cancels in CI) docker container prune # after docker container prune --force --filter "until=24h"
When it happens
Trigger: Running `docker container prune` without --force and answering 'n' (or anything not affirmative) at the 'WARNING! This will remove all stopped containers' prompt; prompt.Confirm returning false, e.g. also when stdin is closed/non-interactive so the confirmation defaults to no.
Common situations: Running the command in CI, cron, or a script where no TTY/stdin is available so confirmation cannot be given; deliberately backing out after reading the warning; wrappers that pipe empty input into the command.
Related errors
- builder prune has been cancelled
- containers prune has been cancelled
- system prune has been cancelled
- volume prune has been cancelled
- conflicting options: cannot specify both --network-alias and
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/ff4968474657e937.json.
Report an issue: GitHub.