mirror of
https://github.com/containers/podman.git
synced 2025-12-01 02:27:13 +08:00
podman rmi: improve error message for build containers
Improve the error message when attempting to remove an image that is in use by an external/build container. Prior, the error only indicated that the image was in use but did not aid in resolving the issue. Fixes: #15006 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
9
vendor/github.com/containers/common/libimage/image.go
generated
vendored
9
vendor/github.com/containers/common/libimage/image.go
generated
vendored
@@ -470,6 +470,9 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
}
|
||||
|
||||
if _, err := i.runtime.store.DeleteImage(i.ID(), true); handleError(err) != nil {
|
||||
if errors.Is(err, storage.ErrImageUsedByContainer) {
|
||||
err = fmt.Errorf("%w: consider listing external containers and force-removing image", err)
|
||||
}
|
||||
return processedIDs, err
|
||||
}
|
||||
report.Untagged = append(report.Untagged, i.Names()...)
|
||||
@@ -478,6 +481,11 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
report.Removed = true
|
||||
}
|
||||
|
||||
// Do not delete any parents if NoPrune is true
|
||||
if options.NoPrune {
|
||||
return processedIDs, nil
|
||||
}
|
||||
|
||||
// Check if can remove the parent image.
|
||||
if parent == nil {
|
||||
return processedIDs, nil
|
||||
@@ -495,7 +503,6 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
if !danglingParent {
|
||||
return processedIDs, nil
|
||||
}
|
||||
|
||||
// Recurse into removing the parent.
|
||||
return parent.removeRecursive(ctx, rmMap, processedIDs, "", options)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user