...
1## update
2
3<!---MARKER_GEN_START-->
4Update configuration of one or more containers
5
6### Aliases
7
8`docker container update`, `docker update`
9
10### Options
11
12| Name | Type | Default | Description |
13|:---------------------------------------------------|:----------|:--------|:-----------------------------------------------------------------------------|
14| `--blkio-weight` | `uint16` | `0` | Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) |
15| `--cpu-period` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) period |
16| `--cpu-quota` | `int64` | `0` | Limit CPU CFS (Completely Fair Scheduler) quota |
17| `--cpu-rt-period` | `int64` | `0` | Limit the CPU real-time period in microseconds |
18| `--cpu-rt-runtime` | `int64` | `0` | Limit the CPU real-time runtime in microseconds |
19| [`-c`](#cpu-shares), [`--cpu-shares`](#cpu-shares) | `int64` | `0` | CPU shares (relative weight) |
20| `--cpus` | `decimal` | | Number of CPUs |
21| `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) |
22| `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) |
23| [`-m`](#memory), [`--memory`](#memory) | `bytes` | `0` | Memory limit |
24| `--memory-reservation` | `bytes` | `0` | Memory soft limit |
25| `--memory-swap` | `bytes` | `0` | Swap limit equal to memory plus swap: -1 to enable unlimited swap |
26| `--pids-limit` | `int64` | `0` | Tune container pids limit (set -1 for unlimited) |
27| [`--restart`](#restart) | `string` | | Restart policy to apply when a container exits |
28
29
30<!---MARKER_GEN_END-->
31
32## Description
33
34The `docker update` command dynamically updates container configuration.
35You can use this command to prevent containers from consuming too many
36resources from their Docker host. With a single command, you can place
37limits on a single container or on many. To specify more than one container,
38provide space-separated list of container names or IDs.
39
40With the exception of the `--kernel-memory` option, you can specify these
41options on a running or a stopped container. On kernel version older than
424.6, you can only update `--kernel-memory` on a stopped container or on
43a running container with kernel memory initialized.
44
45> **Warning**
46>
47> The `docker update` and `docker container update` commands are not supported
48> for Windows containers.
49{ .warning }
50
51## Examples
52
53The following sections illustrate ways to use this command.
54
55### <a name="cpu-shares"></a> Update a container's cpu-shares (--cpu-shares)
56
57To limit a container's cpu-shares to 512, first identify the container
58name or ID. You can use `docker ps` to find these values. You can also
59use the ID returned from the `docker run` command. Then, do the following:
60
61```console
62$ docker update --cpu-shares 512 abebf7571666
63```
64
65### <a name="memory"></a> Update a container with cpu-shares and memory (-m, --memory)
66
67To update multiple resource configurations for multiple containers:
68
69```console
70$ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
71```
72
73### <a name="kernel-memory"></a> Update a container's kernel memory constraints (--kernel-memory)
74
75You can update a container's kernel memory limit using the `--kernel-memory`
76option. On kernel version older than 4.6, this option can be updated on a
77running container only if the container was started with `--kernel-memory`.
78If the container was started without `--kernel-memory` you need to stop
79the container before updating kernel memory.
80
81> **Note**
82>
83> The `--kernel-memory` option has been deprecated since Docker 20.10.
84
85For example, if you started a container with this command:
86
87```console
88$ docker run -dit --name test --kernel-memory 50M ubuntu bash
89```
90
91You can update kernel memory while the container is running:
92
93```console
94$ docker update --kernel-memory 80M test
95```
96
97If you started a container without kernel memory initialized:
98
99```console
100$ docker run -dit --name test2 --memory 300M ubuntu bash
101```
102
103Update kernel memory of running container `test2` will fail. You need to stop
104the container before updating the `--kernel-memory` setting. The next time you
105start it, the container uses the new value.
106
107Kernel version newer than (include) 4.6 does not have this limitation, you
108can use `--kernel-memory` the same way as other options.
109
110### <a name="restart"></a> Update a container's restart policy (--restart)
111
112You can change a container's restart policy on a running container. The new
113restart policy takes effect instantly after you run `docker update` on a
114container.
115
116To update restart policy for one or more containers:
117
118```console
119$ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
120```
121
122Note that if the container is started with `--rm` flag, you cannot update the restart
123policy for it. The `AutoRemove` and `RestartPolicy` are mutually exclusive for the
124container.
View as plain text