Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Docker update command

Docker update command

Docker Command ReferenceDocker Command Reference


docker update The command is used to update the resource limits of a Docker container, including memory, CPU, and so on.

docker updateThe command can dynamically adjust resource limits while a container is running, without stopping and restarting it.

Syntax

docker update [OPTIONS] CONTAINER [CONTAINER...]

Common parameters

Common OPTIONS:

1、--memory, -m: Set the container's memory limit.

docker update -m 2g my_container

2、--memory-swap: Set the total limit on the container's memory and swap space. If set to -1, swap space is unlimited.

docker update --memory-swap 3g my_container

3、--cpu-shares: Set the container's CPU priority, a relative value. The default is 1024; a larger value indicates a higher priority.

docker update --cpu-shares 2048 my_container

4、--cpus: Set the number of CPU cores used by the container. This option can limit the maximum number of CPU cores a container can use.

docker update --cpus 2 my_container

5、--cpu-period: Set the CPU period. Used together with --cpu-quota to limit the container's CPU usage time. The unit is microseconds (default value:100000 microseconds = 100ms).

docker update --cpu-period 50000 my_container

6、--cpu-quota: Set the maximum CPU time a container can use in each period. The unit is microseconds. It needs to be used with --cpu-period .

docker update --cpu-quota 25000 my_container

7、--blkio-weight: Set the block I/O weight (range:10 to 1000), indicating the container's priority for disk I/O operations. The default value is 500。

docker update --blkio-weight 800 my_container

8、--pids-limit: Set the maximum number of processes the container can use.

docker update --pids-limit 200 my_container

9、--restart: Set the container's restart policy (no、on-failure、always、unless-stopped)。

docker update --restart always my_container

Example

** 1. Update a container's memory limit:**



docker update -m 2g my_container

This command updates the memory limit of my_container to 2GB.

2. Set the CPU core count limit:



docker update --cpus 1.5 my_container

This command limits my_container to using at most 1.5 CPU cores.

** 3. Update a container's CPU weight:**



docker update --cpu-shares 1024 my_container

This command sets the container's CPU weight to 1024, which is the default value.

** 4. Update a container's block I/O weight:**



docker update --blkio-weight 700 my_container

This command sets the container's disk I/O weight to 700; the weight range is 10 to 1000.

Usage limitations


Docker Command ReferenceDocker Command Reference