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...]
Updates container resource limits
Update configuration of one or more containers
--help=false Print usage
--blkio-weight=0 Block IO (relative weight), between 10 and 1000
@ -25,11 +25,12 @@ parent = "smn_cli"
--memory-reservation="" Memory soft limit
--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
--restart Restart policy to apply when a container exits
The `docker update` command dynamically updates container resources. Use this
command to prevent containers from consuming too many resources from their
Docker host. With a single command, you can place limits on a single
container or on many. To specify more than one container, provide
The `docker update` command dynamically updates container configuration.
You can use this command to prevent containers from consuming too many resources
from their Docker host. With a single command, you can place limits on
a single container or on many. To specify more than one container, provide
space-separated list of container names or IDs.
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
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
The following sections illustrate ways to use this command.
@ -59,3 +64,10 @@ To update multiple resource configurations for multiple containers:
```bash
$ 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
% JUNE 2014
# NAME
docker-update - Update resource configs of one or more containers
docker-update - Update configuration of one or more containers
# SYNOPSIS
**docker update**
@ -17,15 +17,16 @@ docker-update - Update resource configs of one or more containers
[**-m**|**--memory**[=*MEMORY*]]
[**--memory-reservation**[=*MEMORY-RESERVATION*]]
[**--memory-swap**[=*MEMORY-SWAP*]]
[**--restart**[=*""*]]
CONTAINER [CONTAINER...]
# DESCRIPTION
The `docker update` command dynamically updates container resources. Use this
command to prevent containers from consuming too many resources from their
Docker host. With a single command, you can place limits on a single
container or on many. To specify more than one container, provide
space-separated list of container names or IDs.
The `docker update` command dynamically updates container configuration.
you can Use this command to prevent containers from consuming too many
resources from their Docker host. With a single command, you can place
limits on a single container or on many. To specify more than one container,
provide space-separated list of container names or IDs.
With the exception of the `--kernel-memory` value, you can specify these
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
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
**--blkio-weight**=0
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**=""
Total memory limit (memory + swap)
**--restart**=""
Restart policy to apply when a container exits (no, on-failure[:max-retry], always, unless-stopped).
# EXAMPLES
The following sections illustrate ways to use this command.
@ -91,3 +99,10 @@ To update multiple resource configurations for multiple containers:
```bash
$ 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
```