1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Set default restart policy name to 'no' Closes #10874

Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
Lei Jitang 2015-03-10 10:09:12 +08:00
parent 1ff904e045
commit 311a600f19
5 changed files with 23 additions and 4 deletions

View file

@ -157,7 +157,7 @@ This value should always larger than **-m**, so you should alway use this with *
**--read-only**=*true*|*false* **--read-only**=*true*|*false*
Mount the container's root filesystem as read only. Mount the container's root filesystem as read only.
**--restart**="" **--restart**="no"
Restart policy to apply when a container exits (no, on-failure[:max-retry], always) Restart policy to apply when a container exits (no, on-failure[:max-retry], always)
**--security-opt**=[] **--security-opt**=[]

View file

@ -280,7 +280,7 @@ outside of a container on the host.
to write files anywhere. By specifying the `--read-only` flag the container will have to write files anywhere. By specifying the `--read-only` flag the container will have
its root filesystem mounted as read only prohibiting any writes. its root filesystem mounted as read only prohibiting any writes.
**--restart**="" **--restart**="no"
Restart policy to apply when a container exits (no, on-failure[:max-retry], always) Restart policy to apply when a container exits (no, on-failure[:max-retry], always)
**--rm**=*true*|*false* **--rm**=*true*|*false*

View file

@ -799,7 +799,7 @@ Creates a new container.
-p, --publish=[] Publish a container's port(s) to the host -p, --publish=[] Publish a container's port(s) to the host
--privileged=false Give extended privileges to this container --privileged=false Give extended privileges to this container
--read-only=false Mount the container's root filesystem as read only --read-only=false Mount the container's root filesystem as read only
--restart="" Restart policy to apply when a container exits --restart="no" Restart policy to apply when a container exits
--security-opt=[] Security Options --security-opt=[] Security Options
-t, --tty=false Allocate a pseudo-TTY -t, --tty=false Allocate a pseudo-TTY
-u, --user="" Username or UID -u, --user="" Username or UID

View file

@ -3178,6 +3178,25 @@ func TestRunOOMExitCode(t *testing.T) {
logDone("run - exit code on oom") logDone("run - exit code on oom")
} }
func TestRunSetDefaultRestartPolicy(t *testing.T) {
defer deleteAllContainers()
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "test", "busybox", "top")
if out, _, err := runCommandWithOutput(runCmd); err != nil {
t.Fatalf("failed to run container: %v, output: %q", err, out)
}
cmd := exec.Command(dockerBinary, "inspect", "-f", "{{.HostConfig.RestartPolicy.Name}}", "test")
out, _, err := runCommandWithOutput(cmd)
if err != nil {
t.Fatalf("failed to inspect container: %v, output: %q", err, out)
}
out = strings.Trim(out, "\r\n")
if out != "no" {
t.Fatalf("Set default restart policy failed")
}
logDone("run - set default restart policy success")
}
func TestRunRestartMaxRetries(t *testing.T) { func TestRunRestartMaxRetries(t *testing.T) {
defer deleteAllContainers() defer deleteAllContainers()
out, err := exec.Command(dockerBinary, "run", "-d", "--restart=on-failure:3", "busybox", "false").CombinedOutput() out, err := exec.Command(dockerBinary, "run", "-d", "--restart=on-failure:3", "busybox", "false").CombinedOutput()

View file

@ -66,7 +66,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container") flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container")
flMacAddress = cmd.String([]string{"-mac-address"}, "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)") flMacAddress = cmd.String([]string{"-mac-address"}, "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)")
flIpcMode = cmd.String([]string{"-ipc"}, "", "IPC namespace to use") flIpcMode = cmd.String([]string{"-ipc"}, "", "IPC namespace to use")
flRestartPolicy = cmd.String([]string{"-restart"}, "", "Restart policy to apply when a container exits") flRestartPolicy = cmd.String([]string{"-restart"}, "no", "Restart policy to apply when a container exits")
flReadonlyRootfs = cmd.Bool([]string{"-read-only"}, false, "Mount the container's root filesystem as read only") flReadonlyRootfs = cmd.Bool([]string{"-read-only"}, false, "Mount the container's root filesystem as read only")
) )