docker/cli · info · cancelledErr
builder prune has been cancelled
Error message
builder prune has been cancelled
What it means
docker builder prune asks for interactive confirmation before deleting build cache unless --force is given. When the user answers 'no' (or the prompt is declined), runPrune returns a cancelledErr wrapping this message, which the CLI maps to a cancelled-operation exit rather than performing any prune. The cancelledErr type implements a Cancelled() marker so upstream code exits without treating it as a hard failure.
Source
Thrown at cli/command/builder/prune.go:84
const (
normalWarning = `WARNING! This will remove all dangling build cache. Are you sure you want to continue?`
allCacheWarning = `WARNING! This will remove all build cache. Are you sure you want to continue?`
)
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
warning := normalWarning
if options.all {
warning = allCacheWarning
}
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("builder prune has been cancelled")}
}
}
resp, err := dockerCli.Client().BuildCachePrune(ctx, client.BuildCachePruneOptions{
All: options.all,
ReservedSpace: options.reservedSpace.Value(),
Filters: pruneFilters,
})
if err != nil {
return 0, "", err
}
report := resp.Report
if len(report.CachesDeleted) > 0 {
var sb strings.Builder
sb.WriteString("Deleted build cache objects:\n")
for _, id := range report.CachesDeleted {
sb.WriteString(id)
sb.WriteByte('\n')View on GitHub (pinned to e9452d6e78)
Solutions
- Pass --force (-f) to skip the confirmation prompt in scripts and CI
- If cancellation was intentional, no action needed — nothing was deleted
- In automation, check for the cancelled marker/exit code and treat it as a no-op rather than a failure
Example fix
# before docker builder prune --all # after (non-interactive) docker builder prune --all --force
When it happens
Trigger: Running docker builder prune (or docker buildx prune via this path) without --force and responding 'N'/enter at the 'Are you sure you want to continue?' prompt; also when prompt.Confirm returns false because stdin is closed or non-interactive.
Common situations: CI scripts running docker builder prune without -f, where stdin is not a TTY so the confirmation defaults to no; users cancelling after seeing the 'remove all build cache' warning with -a; automation wrappers not passing --force.
Related errors
- container prune has been cancelled
- system prune has been cancelled
- volume prune has been cancelled
- containers prune has been cancelled
- image prune has been cancelled
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/b4835649dc69a15d.json.
Report an issue: GitHub.