summaryrefslogtreecommitdiff
path: root/cmd/podman/shared/prune.go
blob: 90cfe44757922f52700e42ee7b6f7a26806e321f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package shared

import (
	"fmt"
	"github.com/pkg/errors"

	"github.com/containers/libpod/libpod/image"
)

// Prune removes all unnamed and unused images from the local store
func Prune(ir *image.Runtime) error {
	pruneImages, err := ir.GetPruneImages()
	if err != nil {
		return err
	}

	for _, i := range pruneImages {
		if err := i.Remove(true); err != nil {
			return errors.Wrapf(err, "failed to remove %s", i.ID())
		}
		fmt.Println(i.ID())
	}
	return nil
}