github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/container_update.md (about) 1 ## update 2 3 <!---MARKER_GEN_START--> 4 Update 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 34 The `docker update` command dynamically updates container configuration. 35 You can use this command to prevent containers from consuming too many 36 resources from their Docker host. With a single command, you can place 37 limits on a single container or on many. To specify more than one container, 38 provide space-separated list of container names or IDs. 39 40 With the exception of the `--kernel-memory` option, you can specify these 41 options on a running or a stopped container. On kernel version older than 42 4.6, you can only update `--kernel-memory` on a stopped container or on 43 a 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 53 The following sections illustrate ways to use this command. 54 55 ### <a name="cpu-shares"></a> Update a container's cpu-shares (--cpu-shares) 56 57 To limit a container's cpu-shares to 512, first identify the container 58 name or ID. You can use `docker ps` to find these values. You can also 59 use 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 67 To 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 75 You can update a container's kernel memory limit using the `--kernel-memory` 76 option. On kernel version older than 4.6, this option can be updated on a 77 running container only if the container was started with `--kernel-memory`. 78 If the container was started without `--kernel-memory` you need to stop 79 the container before updating kernel memory. 80 81 > **Note** 82 > 83 > The `--kernel-memory` option has been deprecated since Docker 20.10. 84 85 For 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 91 You can update kernel memory while the container is running: 92 93 ```console 94 $ docker update --kernel-memory 80M test 95 ``` 96 97 If you started a container without kernel memory initialized: 98 99 ```console 100 $ docker run -dit --name test2 --memory 300M ubuntu bash 101 ``` 102 103 Update kernel memory of running container `test2` will fail. You need to stop 104 the container before updating the `--kernel-memory` setting. The next time you 105 start it, the container uses the new value. 106 107 Kernel version newer than (include) 4.6 does not have this limitation, you 108 can use `--kernel-memory` the same way as other options. 109 110 ### <a name="restart"></a> Update a container's restart policy (--restart) 111 112 You can change a container's restart policy on a running container. The new 113 restart policy takes effect instantly after you run `docker update` on a 114 container. 115 116 To update restart policy for one or more containers: 117 118 ```console 119 $ docker update --restart=on-failure:3 abebf7571666 hopeful_morse 120 ``` 121 122 Note that if the container is started with `--rm` flag, you cannot update the restart 123 policy for it. The `AutoRemove` and `RestartPolicy` are mutually exclusive for the 124 container.