{"record":{"id":"e09c35064686633e","repo":"GoogleContainerTools/skaffold","slug":"pruning-images-w","errorCode":null,"errorMessage":"pruning images: %w","messagePattern":"pruning images: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/skaffold/docker/image.go","lineNumber":746,"sourceCode":"\t\targs = append(args, \"--ssh\", a.SSH)\n\t}\n\n\treturn args, nil\n}\n\nfunc (l *localDaemon) Prune(ctx context.Context, images []string, pruneChildren bool) ([]string, error) {\n\tvar pruned []string\n\tvar errRt error\n\tfor _, id := range images {\n\t\tresp, err := l.ImageRemove(ctx, id, client.ImageRemoveOptions{\n\t\t\tForce:         true,\n\t\t\tPruneChildren: pruneChildren,\n\t\t})\n\t\tif err == nil {\n\t\t\tpruned = append(pruned, id)\n\t\t} else if errRt == nil {\n\t\t\t// save the first error\n\t\t\terrRt = fmt.Errorf(\"pruning images: %w\", err)\n\t\t}\n\n\t\tfor _, r := range resp {\n\t\t\tif r.Deleted != \"\" {\n\t\t\t\tlog.Entry(ctx).Debugf(\"deleted image %s\\n\", r.Deleted)\n\t\t\t}\n\t\t\tif r.Untagged != \"\" {\n\t\t\t\tlog.Entry(ctx).Debugf(\"untagged image %s\\n\", r.Untagged)\n\t\t\t}\n\t\t}\n\t}\n\treturn pruned, errRt\n}\n\nfunc (l *localDaemon) Stop(ctx context.Context, id string, stopTimeout *time.Duration) error {\n\tvar so client.ContainerStopOptions\n\tif stopTimeout != nil {\n\t\tso.Timeout = util.Ptr[int](int(stopTimeout.Seconds()))","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/image.go#L728-L764","documentation":"localDaemon.Prune removes each listed image and records only the FIRST error encountered as errRt, wrapped as \"pruning images: %w\"; all images are still attempted. The returned error therefore represents one (the first) image-removal failure during a batch prune, typically a conflict because an image is in use.","triggerScenarios":"Calling Prune(ctx, images, pruneChildren) where at least one ImageRemove fails (commonly errdefs.Conflict — image in use by a container) while others succeed; the first failure is surfaced in errRt.","commonSituations":"Pruning the local cache while a running or stopped container still uses an image, images tagged for a kind/minikube node, concurrent processes re-creating images mid-prune.","solutions":["Stop and remove containers referencing the images: `docker ps -a --filter ancestor=<image>` then `docker rm`.","Re-run the prune after containers are gone — remaining images usually prune cleanly.","Enable force/children pruning at the call site (PruneChildren: true, Force in ImageRemoveOptions).","Inspect which image failed from the wrapped error message and handle it individually."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// list images still in use before pruning\ninUse := map[string]bool{}\ncs, _ := client.ContainerList(ctx, client.ContainerListOptions{All: true})\nfor _, c := range cs { inUse[c.ImageID] = true }","typeGuard":null,"tryCatchPattern":"pruned, err := daemon.Prune(ctx, images, true)\nif err != nil && strings.Contains(err.Error(), \"pruning images\") {\n    log.Printf(\"some images were pruned (%d ok); first failure: %v — remove containers and retry\", len(pruned), err)\n}","preventionTips":["Remove or stop dependent containers before pruning.","Enable PruneChildren so dependent layers are removed with parents.","Treat partial prune results as normal — the function prunes all images regardless of individual failures.","Run prunes outside active deploy windows to avoid races."],"tags":["docker","prune","cleanup","conflict"],"backgroundTag":"docker-image-conflict","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}