Skip to content

Commit

Permalink
Merge pull request #1210 from allencloud/stop-non-running-container
Browse files Browse the repository at this point in the history
fix: make stopping non-running container valid
  • Loading branch information
HusterWan authored Apr 25, 2018
2 parents 3c308b9 + 347d013 commit 8eae7e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions test/cli_stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8eae7e3

Please sign in to comment.