mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #11235 from coolljt0725/fix_default_restart_name
Set default restart policy name to `no` Closes #10874
This commit is contained in:
commit
7e47bb6eff
5 changed files with 23 additions and 4 deletions
|
@ -157,7 +157,7 @@ This value should always larger than **-m**, so you should alway use this with *
|
|||
**--read-only**=*true*|*false*
|
||||
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)
|
||||
|
||||
**--security-opt**=[]
|
||||
|
|
|
@ -294,7 +294,7 @@ outside of a container on the host.
|
|||
to write files anywhere. By specifying the `--read-only` flag the container will have
|
||||
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)
|
||||
|
||||
**--rm**=*true*|*false*
|
||||
|
|
|
@ -802,7 +802,7 @@ Creates a new container.
|
|||
-p, --publish=[] Publish a container's port(s) to the host
|
||||
--privileged=false Give extended privileges to this container
|
||||
--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
|
||||
-t, --tty=false Allocate a pseudo-TTY
|
||||
-u, --user="" Username or UID
|
||||
|
|
|
@ -3183,6 +3183,25 @@ func TestRunOOMExitCode(t *testing.T) {
|
|||
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) {
|
||||
defer deleteAllContainers()
|
||||
out, err := exec.Command(dockerBinary, "run", "-d", "--restart=on-failure:3", "busybox", "false").CombinedOutput()
|
||||
|
|
|
@ -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")
|
||||
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")
|
||||
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")
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue