diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-11-09 10:28:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 10:28:14 -0800 |
commit | 78e6d8e7d70d431ccf096dee0f8eadb1c9b2967b (patch) | |
tree | 4adf8d4048a6b2c4c89ade6bb9375716d8fe8bd3 /libpod | |
parent | 7813f90ce623c8882e53171c8ffe7fb46664ead7 (diff) | |
parent | 2dd9cae37cb076418393ba61c0fb7b8cf97148f3 (diff) | |
download | podman-78e6d8e7d70d431ccf096dee0f8eadb1c9b2967b.tar.gz podman-78e6d8e7d70d431ccf096dee0f8eadb1c9b2967b.tar.bz2 podman-78e6d8e7d70d431ccf096dee0f8eadb1c9b2967b.zip |
Merge pull request #1772 from baude/rmdelpaused
rm -f now removes a paused container
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime_ctr.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 09dc7c48b..09d0ec042 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -246,7 +246,19 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) } if c.state.State == ContainerStatePaused { - return errors.Wrapf(ErrCtrStateInvalid, "container %s is paused, cannot remove until unpaused", c.ID()) + if !force { + return errors.Wrapf(ErrCtrStateInvalid, "container %s is paused, cannot remove until unpaused", c.ID()) + } + if err := c.runtime.ociRuntime.killContainer(c, 9); err != nil { + return err + } + if err := c.unpause(); err != nil { + return err + } + // Need to update container state to make sure we know it's stopped + if err := c.waitForExitFileAndSync(); err != nil { + return err + } } // Check that the container's in a good state to be removed |