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> Upstream-commit: ff3ea4c90f2ede5cccc6b49c4d2aad7201c91a4c Component: engine
This commit is contained in:
@@ -117,7 +117,7 @@ This section lists each version from latest to oldest. Each listing includes a
|
||||
|
||||
* `GET /containers/json` returns the state of the container, one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`.
|
||||
* `GET /networks/(name)` now returns an `Internal` field showing whether the network is internal or not.
|
||||
|
||||
* `POST /containers/(name)/update` now supports updating container's restart policy.
|
||||
|
||||
### v1.22 API changes
|
||||
|
||||
|
||||
@@ -1031,7 +1031,7 @@ Status Codes:
|
||||
|
||||
`POST /containers/(id)/update`
|
||||
|
||||
Update resource configs of one or more containers.
|
||||
Update configuration of one or more containers.
|
||||
|
||||
**Example request**:
|
||||
|
||||
@@ -1049,6 +1049,10 @@ Update resource configs of one or more containers.
|
||||
"MemorySwap": 514288000,
|
||||
"MemoryReservation": 209715200,
|
||||
"KernelMemory": 52428800,
|
||||
"RestartPolicy": {
|
||||
"MaximumRetryCount": 4,
|
||||
"Name": "on-failure"
|
||||
},
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user