mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +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)
|
||||
}
|
||||
|
3
vendor/github.com/containers/common/libimage/runtime.go
generated
vendored
3
vendor/github.com/containers/common/libimage/runtime.go
generated
vendored
@ -608,6 +608,8 @@ type RemoveImagesOptions struct {
|
||||
// much space was freed. However, computing the size of an image is
|
||||
// comparatively expensive, so it is made optional.
|
||||
WithSize bool
|
||||
// NoPrune will not remove dangling images
|
||||
NoPrune bool
|
||||
}
|
||||
|
||||
// RemoveImages removes images specified by names. If no names are specified,
|
||||
@ -653,7 +655,6 @@ func (r *Runtime) RemoveImages(ctx context.Context, names []string, options *Rem
|
||||
toDelete := []string{}
|
||||
// Look up images in the local containers storage and fill out
|
||||
// toDelete and the deleteMap.
|
||||
|
||||
switch {
|
||||
case len(names) > 0:
|
||||
// prepare lookupOptions
|
||||
|
2
vendor/github.com/containers/common/version/version.go
generated
vendored
2
vendor/github.com/containers/common/version/version.go
generated
vendored
@ -1,4 +1,4 @@
|
||||
package version
|
||||
|
||||
// Version is the version of the build.
|
||||
const Version = "0.49.1-dev"
|
||||
const Version = "0.49.2-dev"
|
||||
|
Reference in New Issue
Block a user