summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-11 15:31:15 +0200
committerGitHub <noreply@github.com>2019-09-11 15:31:15 +0200
commit093013b099cd2397fdf3aedc213d182064be5d27 (patch)
treeab5800cd43f476bfd99d0d38d2e5b221ec682d59
parent9cf852c305a9eadb5eb7471ea171e025bc15d866 (diff)
parent3e92bcbf7103c5469fdb37ca3d6aeb53ef93a48f (diff)
downloadpodman-093013b099cd2397fdf3aedc213d182064be5d27.tar.gz
podman-093013b099cd2397fdf3aedc213d182064be5d27.tar.bz2
podman-093013b099cd2397fdf3aedc213d182064be5d27.zip
Merge pull request #3984 from mheon/prune_no_in_use_error
Do not prune images being used by a container
-rw-r--r--libpod/image/prune.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/libpod/image/prune.go b/libpod/image/prune.go
index 6ef5d321f..006cbdf22 100644
--- a/libpod/image/prune.go
+++ b/libpod/image/prune.go
@@ -4,7 +4,9 @@ import (
"context"
"github.com/containers/libpod/libpod/events"
+ "github.com/containers/storage"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
// GetPruneImages returns a slice of images that have no names/unused
@@ -44,6 +46,10 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool) ([]string, error)
}
for _, p := range pruneImages {
if err := p.Remove(ctx, true); err != nil {
+ if errors.Cause(err) == storage.ErrImageUsedByContainer {
+ logrus.Warnf("Failed to prune image %s as it is in use: %v", p.ID(), err)
+ continue
+ }
return nil, errors.Wrap(err, "failed to prune image")
}
defer p.newImageEvent(events.Prune)