summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/runtime_img.go9
-rw-r--r--pkg/domain/infra/abi/images.go4
2 files changed, 13 insertions, 0 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 6e1105b9e..abefca788 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -325,6 +325,15 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
return "", errors.Wrapf(saveErr, "error pulling image")
}
+// RemoveImageFromStorage goes directly to storage and attempts to remove
+// the specified image. This is dangerous and should only be done if libpod
+// reports that image is not known. This call is useful if you have a corrupted
+// image that was never fully added to the libpod database.
+func (r *Runtime) RemoveImageFromStorage(id string) error {
+ _, err := r.store.DeleteImage(id, true)
+ return err
+}
+
func getImageNames(images []*image.Image) string {
var names string
for i := range images {
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index b1751b8b6..c02eb2bfc 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -640,6 +640,10 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
for _, id := range images {
img, err := ir.Libpod.ImageRuntime().NewFromLocal(id)
if err != nil {
+ // attempt to remove image from storage
+ if forceErr := ir.Libpod.RemoveImageFromStorage(id); forceErr == nil {
+ continue
+ }
rmErrors = append(rmErrors, err)
continue
}