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