From 9e5a0428d1aa45c706f276b4b686a774ab17f095 Mon Sep 17 00:00:00 2001 From: Allen Sun Date: Wed, 25 Apr 2018 12:17:09 +0800 Subject: [PATCH] fix: make stop stopped container return no error Signed-off-by: Allen Sun --- daemon/mgr/container.go | 4 ---- test/cli_stop_test.go | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/daemon/mgr/container.go b/daemon/mgr/container.go index 9739d1ec09..b715bd24f9 100644 --- a/daemon/mgr/container.go +++ b/daemon/mgr/container.go @@ -706,10 +706,6 @@ func (mgr *ContainerManager) Stop(ctx context.Context, name string, timeout int6 c.Lock() defer c.Unlock() - if !c.IsRunning() { - return fmt.Errorf("container's status is not running: %s", c.meta.State.Status) - } - if timeout == 0 { timeout = c.StopTimeout() } diff --git a/test/cli_stop_test.go b/test/cli_stop_test.go index b2673b0dcf..f5a59fee9b 100644 --- a/test/cli_stop_test.go +++ b/test/cli_stop_test.go @@ -41,6 +41,9 @@ func (suite *PouchStopSuite) TestStopWorks(c *check.C) { command.PouchRun("start", name).Assert(c, icmd.Success) + // test stop a running container + command.PouchRun("stop", name).Assert(c, icmd.Success) + // test stop a stopped container command.PouchRun("stop", name).Assert(c, icmd.Success) res := command.PouchRun("ps", "-a")