From 347d0136312212f514ce0f57302629837429088d Mon Sep 17 00:00:00 2001 From: Allen Sun Date: Wed, 25 Apr 2018 13:52:40 +0800 Subject: [PATCH] fix: make stopping non-running container valid Signed-off-by: Allen Sun --- daemon/mgr/container.go | 4 ++-- test/cli_stop_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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