diff --git a/daemon/mgr/container.go b/daemon/mgr/container.go index 474f58bb0..7e97661d6 100644 --- a/daemon/mgr/container.go +++ b/daemon/mgr/container.go @@ -709,8 +709,8 @@ func (mgr *ContainerManager) Stop(ctx context.Context, name string, timeout int6 c.Lock() defer c.Unlock() - if c.IsStopped() { - // stopping a stopped container is valid. + if !c.IsRunning() { + // stopping a non-running container is valid. return nil } diff --git a/test/cli_stop_test.go b/test/cli_stop_test.go index f5a59fee9..66e3631d2 100644 --- a/test/cli_stop_test.go +++ b/test/cli_stop_test.go @@ -39,6 +39,10 @@ func (suite *PouchStopSuite) TestStopWorks(c *check.C) { command.PouchRun("create", "--name", name, busyboxImage, "top").Assert(c, icmd.Success) defer DelContainerForceMultyTime(c, name) + // test stop a created container + command.PouchRun("stop", name).Assert(c, icmd.Success) + + // start the created container command.PouchRun("start", name).Assert(c, icmd.Success) // test stop a running container