docker update
Update the configuration of one or more containers.Official Documentation
usage
$ docker update [OPTIONS] CONTAINER [CONTAINER...]
SeeOptions section OPTIONS
, learn an overview of the available command.
describe
Shoulddocker update
The command updates the container configuration dynamically. You can use this command to prevent containers from consuming too many resources on the Docker host. With a single command, you can limit a single container or multiple containers. To specify multiple containers, provide a space-separated list of container names or IDs.
In addition to--kernel-memory
In addition to options, you can specify these options on running or stopped containers. On kernel versions earlier than 4.6, you can only--kernel-memory
Update on a stopped container or a running container with kernel memory initialized.
warn
Windows containers are not supported
docker update
and command.docker container update
For examples of using this command, see belowExample section。
Options
Name, abbreviation | default | describe |
---|---|---|
--blkio-weight |
Block IO (relative weight), between 10 and 1000, or 0 disabled (default 0) | |
--cpu-period |
Limit CPU CFS (full fair scheduler) cycles | |
--cpu-quota |
Limit CPU CFS (full fair scheduler) quota | |
--cpu-rt-period |
Limit CPU real-time cycles (in microseconds) | |
--cpu-rt-runtime |
Limit CPU real-time running time to microseconds | |
--cpu-shares,-c | CPU share (relative weight) | |
--cpus |
Number of CPUs | |
--cpuset-cpus |
CPU allowed to execute (0-3, 0,1) | |
--cpuset-mems |
MEM allowed to execute (0-3, 0,1) | |
--memory,-m | Memory limit | |
--memory-reservation |
Memory soft limit | |
--memory-swap |
Switch limit equals memory plus swap: -1 Enable unlimited swap | |
--pids-limit |
API 1.40+Adjust container pid limit (setting -1 means unlimited) | |
--restart | Restart policy applied when container exits |
example
The following sections illustrate how to use this command.
Update the container's cpu-shares (–cpu-shares)
To limit the cpu share of the container to 512, first determine the container name or ID. You can usedocker ps
Find these values. You can also use the ID returned from the commanddocker run
. Then, do the following:
$ docker update --cpu-shares 512 abebf7571666
Update containers using cpu-shares and memory (-m, --memory)
To update multiple resource configurations for multiple containers:
$ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
Update the kernel memory constraints of the container (–kernel-memory)
You can use this option to update the kernel memory limit of the container--kernel-memory
. On kernel versions earlier than 4.6, only if the container is--kernel-memory
. If the container has been started*,--kernel-memory
Then you need to stop the container before updating the kernel memory.
notes
Should
--kernel-memory
The option has been deprecated since Docker 20.10.
For example, if you started a container with the following command:
$ docker run -dit --name test --kernel-memory 50M ubuntu bash
You can update kernel memory while the container is running:
$ docker update --kernel-memory 80M test
If you start a container that does not initialize kernel memory:
$ docker run -dit --name test2 --memory 300M ubuntu bash
Update the kernel memory of the running containertest2
Will fail. You need to stop the container before updating the settings--kernel-memory
. The next time you start, the container will use the new value.
There is no such restriction than (inclusive) 4.6, you can use--kernel-memory
Same way as other options.
Update the container's restart policy (–restart)
You can change the container restart policy for running containers.docker update
The new restart policy takes effect immediately after it runs on the container.
To update the restart policy for one or more containers:
$ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
Note that if the container is started with the “–rm” flag, its restart policy cannot be updated. For containers and are mutually exclusiveAutoRemove
。 RestartPolicy
This is the end of this article about the docker update command. For more related docker update command content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!