Skip to content

Commit

Permalink
Merge pull request #3984 from mheon/prune_no_in_use_error
Browse files Browse the repository at this point in the history
Do not prune images being used by a container
  • Loading branch information
openshift-merge-robot authored Sep 11, 2019
2 parents 9cf852c + 3e92bcb commit 093013b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libpod/image/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 093013b

Please sign in to comment.