summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-05-06 13:15:02 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-05-06 13:17:34 -0400
commit5c6ff901ba54656b54a0cc40306d94c7c55b8454 (patch)
treef1bcf616cbb44a99b9ed45f99ed1a3f89c591d7a
parenta9fc570dd844bf1ebd1f106f1b8091882b4a2b29 (diff)
downloadpodman-5c6ff901ba54656b54a0cc40306d94c7c55b8454.tar.gz
podman-5c6ff901ba54656b54a0cc40306d94c7c55b8454.tar.bz2
podman-5c6ff901ba54656b54a0cc40306d94c7c55b8454.zip
Do not remove volumes when --rm removes a container
This duplicates Docker behavior for the `--rm` flag. Fixes #3071 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--docs/podman-create.1.md2
-rw-r--r--docs/podman-run.1.md2
-rw-r--r--pkg/adapter/containers.go7
3 files changed, 7 insertions, 4 deletions
diff --git a/docs/podman-create.1.md b/docs/podman-create.1.md
index 851f5cf3d..3a44c70af 100644
--- a/docs/podman-create.1.md
+++ b/docs/podman-create.1.md
@@ -585,7 +585,7 @@ Automatically remove the container when it exits. The default is *false*.
Note that the container will not be removed when it could not be created or
started successfully. This allows the user to inspect the container after
-failure. The `--rm` flag is incompatible with the `-d` flag.
+failure.
**--rootfs**
diff --git a/docs/podman-run.1.md b/docs/podman-run.1.md
index db90ce50e..a200b12fb 100644
--- a/docs/podman-run.1.md
+++ b/docs/podman-run.1.md
@@ -607,7 +607,7 @@ Automatically remove the container when it exits. The default is *false*.
Note that the container will not be removed when it could not be created or
started successfully. This allows the user to inspect the container after
-failure. The `--rm` flag is incompatible with the `-d` flag.
+failure.
**--rootfs**
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