summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-03-04 10:58:10 -0500
committerGitHub <noreply@github.com>2020-03-04 10:58:10 -0500
commit90eef95cb1591f20f5716225cf9b2c8c415fc3fc (patch)
tree9f19d9affffb9c57b5888e2fb3d12b9c642d4a73 /pkg/adapter/containers.go
parenta8bc423e2989ceff1ee2ca79d6c1bd8314901e11 (diff)
parent11e5c53d1191f7a324f212aa2ca2ec2aad1b4676 (diff)
downloadpodman-90eef95cb1591f20f5716225cf9b2c8c415fc3fc.tar.gz
podman-90eef95cb1591f20f5716225cf9b2c8c415fc3fc.tar.bz2
podman-90eef95cb1591f20f5716225cf9b2c8c415fc3fc.zip
Merge pull request #4772 from boaz0/closes_4628
Add the rmi flag to podman-run to delete container image
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index a5e668b04..a5242270e 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -1112,6 +1112,15 @@ func (r *LocalRuntime) CleanupContainers(ctx context.Context, cli *cliconfig.Cle
} else {
failures[ctr.ID()] = err
}
+
+ if cli.RemoveImage {
+ _, imageName := ctr.Image()
+ if err := removeContainerImage(ctx, ctr, r); err != nil {
+ failures[imageName] = err
+ } else {
+ ok = append(ok, imageName)
+ }
+ }
}
return ok, failures, nil
}
@@ -1131,6 +1140,16 @@ func cleanupContainer(ctx context.Context, ctr *libpod.Container, runtime *Local
return nil
}
+func removeContainerImage(ctx context.Context, ctr *libpod.Container, runtime *LocalRuntime) error {
+ _, imageName := ctr.Image()
+ ctrImage, err := runtime.NewImageFromLocal(imageName)
+ if err != nil {
+ return err
+ }
+ _, err = runtime.RemoveImage(ctx, ctrImage, false)
+ return err
+}
+
// Port displays port information about existing containers
func (r *LocalRuntime) Port(c *cliconfig.PortValues) ([]*Container, error) {
var (