diff options
-rw-r--r-- | cmd/podman/stop.go | 2 | ||||
-rw-r--r-- | libpod/container_api.go | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index 1d112ffe5..5bfa05708 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -101,7 +101,7 @@ func stopCmd(c *cli.Context) error { } else { stopTimeout = ctr.StopTimeout() } - if err := ctr.StopWithTimeout(stopTimeout); err != nil { + if err := ctr.StopWithTimeout(stopTimeout); err != nil && err != libpod.ErrCtrStopped { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) } diff --git a/libpod/container_api.go b/libpod/container_api.go index 41e754587..6106cfc12 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -215,6 +215,10 @@ func (c *Container) Stop() error { return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers") } + if c.state.State == ContainerStateStopped { + return ErrCtrStopped + } + return c.stop(c.config.StopTimeout) } @@ -237,6 +241,10 @@ func (c *Container) StopWithTimeout(timeout uint) error { return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers") } + if c.state.State == ContainerStateStopped { + return ErrCtrStopped + } + return c.stop(timeout) } |