mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update RestartPolicy of container
Add `--restart` flag for `update` command, so we can change restart policy for a container no matter it's running or stopped. Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
parent
6668326aa8
commit
ff3ea4c90f
17 changed files with 154 additions and 33 deletions
31
integration-cli/docker_cli_update_test.go
Normal file
31
integration-cli/docker_cli_update_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) {
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "sh", "-c", "sleep 1 && false")
|
||||
timeout := 60 * time.Second
|
||||
if daemonPlatform == "windows" {
|
||||
timeout = 100 * time.Second
|
||||
}
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
|
||||
// update restart policy to on-failure:5
|
||||
dockerCmd(c, "update", "--restart=on-failure:5", id)
|
||||
|
||||
err := waitExited(id, timeout)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
count := inspectField(c, id, "RestartCount")
|
||||
c.Assert(count, checker.Equals, "5")
|
||||
|
||||
maximumRetryCount := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
||||
c.Assert(maximumRetryCount, checker.Equals, "5")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue