aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-02-09 05:33:14 -0700
committerDaniel J Walsh <dwalsh@redhat.com>2019-02-09 05:33:14 -0700
commit233ba5bd894aac77db1bb2e41b0ef464f865d2a0 (patch)
treee937c8b78b0bc53374fa45f94e909582ed2c402c /cmd/podman
parent1fd9be022fc1484c9bdebfc41008d2344237073c (diff)
downloadpodman-233ba5bd894aac77db1bb2e41b0ef464f865d2a0.tar.gz
podman-233ba5bd894aac77db1bb2e41b0ef464f865d2a0.tar.bz2
podman-233ba5bd894aac77db1bb2e41b0ef464f865d2a0.zip
Remove container from storage on --force
Currently we can get into a state where a container exists in storage but does not exist in libpod. If the user forces a removal of this container, then we should remove it from storage even if the container is owned by another tool. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/rm.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go
index bb9a913c9..ab2a29e07 100644
--- a/cmd/podman/rm.go
+++ b/cmd/podman/rm.go
@@ -6,6 +6,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/cmd/podman/shared"
+ "github.com/containers/libpod/libpod"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -61,10 +62,18 @@ func rmCmd(c *cliconfig.RmValues) error {
delContainers, err := getAllOrLatestContainers(&c.PodmanCommand, runtime, -1, "all")
if err != nil {
+ if c.Force && len(c.InputArgs) > 0 {
+ if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ err = nil
+ }
+ runtime.RemoveContainersFromStorage(c.InputArgs)
+ }
if len(delContainers) == 0 {
return err
}
- fmt.Println(err.Error())
+ if err != nil {
+ fmt.Println(err.Error())
+ }
}
for _, container := range delContainers {