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:
Zhang Wei 2016-01-04 23:58:20 +08:00 committed by Tibor Vass
parent 776757ac28
commit 623082a1eb
2 changed files with 38 additions and 11 deletions

View File

@ -12,7 +12,7 @@ parent = "smn_cli"
Usage: docker update [OPTIONS] CONTAINER [CONTAINER...] Usage: docker update [OPTIONS] CONTAINER [CONTAINER...]
Updates container resource limits Update configuration of one or more containers
--help=false Print usage --help=false Print usage
--blkio-weight=0 Block IO (relative weight), between 10 and 1000 --blkio-weight=0 Block IO (relative weight), between 10 and 1000
@ -25,11 +25,12 @@ parent = "smn_cli"
--memory-reservation="" Memory soft limit --memory-reservation="" Memory soft limit
--memory-swap="" A positive integer equal to memory plus swap. Specify -1 to enable unlimited swap --memory-swap="" A positive integer equal to memory plus swap. Specify -1 to enable unlimited swap
--kernel-memory="" Kernel memory limit: container must be stopped --kernel-memory="" Kernel memory limit: container must be stopped
--restart Restart policy to apply when a container exits
The `docker update` command dynamically updates container resources. Use this The `docker update` command dynamically updates container configuration.
command to prevent containers from consuming too many resources from their You can use this command to prevent containers from consuming too many resources
Docker host. With a single command, you can place limits on a single from their Docker host. With a single command, you can place limits on
container or on many. To specify more than one container, provide a single container or on many. To specify more than one container, provide
space-separated list of container names or IDs. space-separated list of container names or IDs.
With the exception of the `--kernel-memory` value, you can specify these With the exception of the `--kernel-memory` value, you can specify these
@ -38,6 +39,10 @@ options on a running or a stopped container. You can only update
stopped container, the next time you restart it, the container uses those stopped container, the next time you restart it, the container uses those
values. values.
Another configuration you can change with this command is restart policy,
new restart policy will take effect instantly after you run `docker update`
on a container.
## EXAMPLES ## EXAMPLES
The following sections illustrate ways to use this command. The following sections illustrate ways to use this command.
@ -59,3 +64,10 @@ To update multiple resource configurations for multiple containers:
```bash ```bash
$ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse $ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
``` ```
### Update a container's restart policy
To update restart policy for one or more containers:
```bash
$ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
```

View File

@ -2,7 +2,7 @@
% Docker Community % Docker Community
% JUNE 2014 % JUNE 2014
# NAME # NAME
docker-update - Update resource configs of one or more containers docker-update - Update configuration of one or more containers
# SYNOPSIS # SYNOPSIS
**docker update** **docker update**
@ -17,15 +17,16 @@ docker-update - Update resource configs of one or more containers
[**-m**|**--memory**[=*MEMORY*]] [**-m**|**--memory**[=*MEMORY*]]
[**--memory-reservation**[=*MEMORY-RESERVATION*]] [**--memory-reservation**[=*MEMORY-RESERVATION*]]
[**--memory-swap**[=*MEMORY-SWAP*]] [**--memory-swap**[=*MEMORY-SWAP*]]
[**--restart**[=*""*]]
CONTAINER [CONTAINER...] CONTAINER [CONTAINER...]
# DESCRIPTION # DESCRIPTION
The `docker update` command dynamically updates container resources. Use this The `docker update` command dynamically updates container configuration.
command to prevent containers from consuming too many resources from their you can Use this command to prevent containers from consuming too many
Docker host. With a single command, you can place limits on a single resources from their Docker host. With a single command, you can place
container or on many. To specify more than one container, provide limits on a single container or on many. To specify more than one container,
space-separated list of container names or IDs. provide space-separated list of container names or IDs.
With the exception of the `--kernel-memory` value, you can specify these With the exception of the `--kernel-memory` value, you can specify these
options on a running or a stopped container. You can only update options on a running or a stopped container. You can only update
@ -33,6 +34,10 @@ options on a running or a stopped container. You can only update
stopped container, the next time you restart it, the container uses those stopped container, the next time you restart it, the container uses those
values. values.
Another configuration you can change with this command is restart policy,
new restart policy will take effect instantly after you run `docker update`
on a container.
# OPTIONS # OPTIONS
**--blkio-weight**=0 **--blkio-weight**=0
Block IO weight (relative weight) accepts a weight value between 10 and 1000. Block IO weight (relative weight) accepts a weight value between 10 and 1000.
@ -70,6 +75,9 @@ be updated to a stopped container, and affect after it's started.
**--memory-swap**="" **--memory-swap**=""
Total memory limit (memory + swap) Total memory limit (memory + swap)
**--restart**=""
Restart policy to apply when a container exits (no, on-failure[:max-retry], always, unless-stopped).
# EXAMPLES # EXAMPLES
The following sections illustrate ways to use this command. The following sections illustrate ways to use this command.
@ -91,3 +99,10 @@ To update multiple resource configurations for multiple containers:
```bash ```bash
$ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse $ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
``` ```
### Update a container's restart policy
To update restart policy for one or more containers:
```bash
$ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
```