github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/man/docker-update.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % Docker Community 3 % JUNE 2014 4 # NAME 5 docker-update - Update configuration of one or more containers 6 7 # SYNOPSIS 8 **docker update** 9 [**--blkio-weight**[=*[BLKIO-WEIGHT]*]] 10 [**--cpu-shares**[=*0*]] 11 [**--cpu-period**[=*0*]] 12 [**--cpu-quota**[=*0*]] 13 [**--cpu-rt-period**[=*0*]] 14 [**--cpu-rt-runtime**[=*0*]] 15 [**--cpuset-cpus**[=*CPUSET-CPUS*]] 16 [**--cpuset-mems**[=*CPUSET-MEMS*]] 17 [**--help**] 18 [**--kernel-memory**[=*KERNEL-MEMORY*]] 19 [**-m**|**--memory**[=*MEMORY*]] 20 [**--memory-reservation**[=*MEMORY-RESERVATION*]] 21 [**--memory-swap**[=*MEMORY-SWAP*]] 22 [**--restart**[=*""*]] 23 CONTAINER [CONTAINER...] 24 25 # DESCRIPTION 26 27 The **docker update** command dynamically updates container configuration. 28 You can use this command to prevent containers from consuming too many 29 resources from their Docker host. With a single command, you can place 30 limits on a single container or on many. To specify more than one container, 31 provide space-separated list of container names or IDs. 32 33 With the exception of the **--kernel-memory** option, you can specify these 34 options on a running or a stopped container. On kernel version older than 35 4.6, You can only update **--kernel-memory** on a stopped container or on 36 a running container with kernel memory initialized. 37 38 # OPTIONS 39 40 **--blkio-weight**=0 41 Block IO weight (relative weight) accepts a weight value between 10 and 1000. 42 43 **--cpu-shares**=0 44 CPU shares (relative weight) 45 46 **--cpu-period**=0 47 Limit the CPU CFS (Completely Fair Scheduler) period 48 49 Limit the container's CPU usage. This flag tell the kernel to restrict the container's CPU usage to the period you specify. 50 51 **--cpu-quota**=0 52 Limit the CPU CFS (Completely Fair Scheduler) quota 53 54 **--cpu-rt-period**=0 55 Limit the CPU real-time period in microseconds 56 57 Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. 58 59 **--cpu-rt-runtime**=0 60 Limit the CPU real-time runtime in microseconds 61 62 Limit the containers Real Time CPU usage. This flag tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: 63 Period of 1,000,000us and Runtime of 950,000us means that this container could consume 95% of available CPU and leave the remaining 5% to normal priority tasks. 64 65 The sum of all runtimes across containers cannot exceed the amount allotted to the parent cgroup. 66 67 **--cpuset-cpus**="" 68 CPUs in which to allow execution (0-3, 0,1) 69 70 **--cpuset-mems**="" 71 Memory nodes(MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 72 73 **--help** 74 Print usage statement 75 76 **--kernel-memory**="" 77 Kernel memory limit (format: `<number>[<unit>]`, where unit = b, k, m or g) 78 79 Note that on kernel version older than 4.6, you can not update kernel memory on 80 a running container if the container is started without kernel memory initialized, 81 in this case, it can only be updated after it's stopped. The new setting takes 82 effect when the container is started. 83 84 **-m**, **--memory**="" 85 Memory limit (format: <number><optional unit>, where unit = b, k, m or g) 86 87 Note that the memory should be smaller than the already set swap memory limit. 88 If you want update a memory limit bigger than the already set swap memory limit, 89 you should update swap memory limit at the same time. If you don't set swap memory 90 limit on docker create/run but only memory limit, the swap memory is double 91 the memory limit. 92 93 **--memory-reservation**="" 94 Memory soft limit (format: <number>[<unit>], where unit = b, k, m or g) 95 96 **--memory-swap**="" 97 Total memory limit (memory + swap) 98 99 **--restart**="" 100 Restart policy to apply when a container exits (no, on-failure[:max-retry], always, unless-stopped). 101 102 # EXAMPLES 103 104 The following sections illustrate ways to use this command. 105 106 ### Update a container's cpu-shares 107 108 To limit a container's cpu-shares to 512, first identify the container 109 name or ID. You can use **docker ps** to find these values. You can also 110 use the ID returned from the **docker run** command. Then, do the following: 111 112 ```bash 113 $ docker update --cpu-shares 512 abebf7571666 114 ``` 115 116 ### Update a container with cpu-shares and memory 117 118 To update multiple resource configurations for multiple containers: 119 120 ```bash 121 $ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse 122 ``` 123 124 ### Update a container's kernel memory constraints 125 126 You can update a container's kernel memory limit using the **--kernel-memory** 127 option. On kernel version older than 4.6, this option can be updated on a 128 running container only if the container was started with **--kernel-memory**. 129 If the container was started *without* **--kernel-memory** you need to stop 130 the container before updating kernel memory. 131 132 For example, if you started a container with this command: 133 134 ```bash 135 $ docker run -dit --name test --kernel-memory 50M ubuntu bash 136 ``` 137 138 You can update kernel memory while the container is running: 139 140 ```bash 141 $ docker update --kernel-memory 80M test 142 ``` 143 144 If you started a container *without* kernel memory initialized: 145 146 ```bash 147 $ docker run -dit --name test2 --memory 300M ubuntu bash 148 ``` 149 150 Update kernel memory of running container `test2` will fail. You need to stop 151 the container before updating the **--kernel-memory** setting. The next time you 152 start it, the container uses the new value. 153 154 Kernel version newer than (include) 4.6 does not have this limitation, you 155 can use `--kernel-memory` the same way as other options. 156 157 ### Update a container's restart policy 158 159 You can change a container's restart policy on a running container. The new 160 restart policy takes effect instantly after you run `docker update` on a 161 container. 162 163 To update restart policy for one or more containers: 164 165 ```bash 166 $ docker update --restart=on-failure:3 abebf7571666 hopeful_morse 167 ``` 168 169 Note that if the container is started with "--rm" flag, you cannot update the restart 170 policy for it. The `AutoRemove` and `RestartPolicy` are mutually exclusive for the 171 container.