From 5c6ff901ba54656b54a0cc40306d94c7c55b8454 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 6 May 2019 13:15:02 -0400 Subject: Do not remove volumes when --rm removes a container This duplicates Docker behavior for the `--rm` flag. Fixes #3071 Signed-off-by: Matthew Heon --- pkg/adapter/containers.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg') diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 0721af773..f17050d42 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -413,7 +413,9 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode } if c.IsSet("rm") { - r.Runtime.RemoveContainer(ctx, ctr, false, true) + if err := r.Runtime.RemoveContainer(ctx, ctr, false, false); err != nil { + logrus.Errorf("Error removing container %s: %v", ctr.ID(), err) + } } return exitCode, nil @@ -965,8 +967,9 @@ func (r *LocalRuntime) CleanupContainers(ctx context.Context, cli *cliconfig.Cle return ok, failures, nil } +// Only used when cleaning up containers func removeContainer(ctx context.Context, ctr *libpod.Container, runtime *LocalRuntime) error { - if err := runtime.RemoveContainer(ctx, ctr, false, true); err != nil { + if err := runtime.RemoveContainer(ctx, ctr, false, false); err != nil { return errors.Wrapf(err, "failed to cleanup and remove container %v", ctr.ID()) } return nil -- cgit v1.2.3-54-g00ecf