diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/containers.go | 19 | ||||
-rw-r--r-- | pkg/env/env.go | 3 | ||||
-rw-r--r-- | pkg/spec/createconfig.go | 5 |
3 files changed, 26 insertions, 1 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 ( diff --git a/pkg/env/env.go b/pkg/env/env.go index 31ffab03c..9c0ee79db 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -62,7 +62,8 @@ func Join(base map[string]string, override map[string]string) map[string]string // ParseFile parses the specified path for environment variables and returns them // as a map. -func ParseFile(path string) (env map[string]string, err error) { +func ParseFile(path string) (_ map[string]string, err error) { + env := make(map[string]string) defer func() { if err != nil { err = errors.Wrapf(err, "error parsing env file %q", path) diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 1d9633bb3..9b2255d61 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -157,6 +157,7 @@ type CreateConfig struct { Resources CreateResourceConfig RestartPolicy string Rm bool //rm + Rmi bool //rmi StopSignal syscall.Signal // stop-signal StopTimeout uint // stop-timeout Systemd bool @@ -234,6 +235,10 @@ func (c *CreateConfig) createExitCommand(runtime *libpod.Runtime) ([]string, err command = append(command, "--rm") } + if c.Rmi { + command = append(command, "--rmi") + } + return command, nil } |