|
@@ -74,7 +74,7 @@ func (s *DockerSuite) TestRestartWithVolumes(c *check.C) {
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestRestartPolicyNO(c *check.C) {
|
|
|
- out, _ := dockerCmd(c, "run", "-d", "--restart=no", "busybox", "false")
|
|
|
+ out, _ := dockerCmd(c, "create", "--restart=no", "busybox")
|
|
|
|
|
|
id := strings.TrimSpace(string(out))
|
|
|
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
|
@@ -82,7 +82,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *check.C) {
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) {
|
|
|
- out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
|
|
|
+ out, _ := dockerCmd(c, "create", "--restart=always", "busybox")
|
|
|
|
|
|
id := strings.TrimSpace(string(out))
|
|
|
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
|
@@ -95,12 +95,36 @@ func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) {
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) {
|
|
|
- out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:1", "busybox", "false")
|
|
|
+ out, _, err := dockerCmdWithError("create", "--restart=on-failure:-1", "busybox")
|
|
|
+ c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
+ c.Assert(out, checker.Contains, "maximum retry count cannot be negative")
|
|
|
+
|
|
|
+ out, _ = dockerCmd(c, "create", "--restart=on-failure:1", "busybox")
|
|
|
|
|
|
id := strings.TrimSpace(string(out))
|
|
|
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
|
|
+ maxRetry := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
|
|
+
|
|
|
c.Assert(name, checker.Equals, "on-failure")
|
|
|
+ c.Assert(maxRetry, checker.Equals, "1")
|
|
|
+
|
|
|
+ out, _ = dockerCmd(c, "create", "--restart=on-failure:0", "busybox")
|
|
|
|
|
|
+ id = strings.TrimSpace(string(out))
|
|
|
+ name = inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
|
|
+ maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
|
|
+
|
|
|
+ c.Assert(name, checker.Equals, "on-failure")
|
|
|
+ c.Assert(maxRetry, checker.Equals, "0")
|
|
|
+
|
|
|
+ out, _ = dockerCmd(c, "create", "--restart=on-failure", "busybox")
|
|
|
+
|
|
|
+ id = strings.TrimSpace(string(out))
|
|
|
+ name = inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
|
|
+ maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
|
|
+
|
|
|
+ c.Assert(name, checker.Equals, "on-failure")
|
|
|
+ c.Assert(maxRetry, checker.Equals, "0")
|
|
|
}
|
|
|
|
|
|
// a good container with --restart=on-failure:3
|