\\n \\n \\n \\n \\n \\n \\n \\n For example: \\n \\n --memory-swap: Sets the total limit for the container's memory and swap space. If set to `-1`, it means no limit on swap space.\\n \\n--cpu-shares: Sets the CPU priority of the container, relative value. Default is `1024`, larger values indicate higher priority.\\n \\n --cpus: Set the number of CPU cores used by the container. This option can limit the maximum number of CPU cores the container can use.\\n \\n --cpu-period: Sets the CPU period. Used in conjunction with `--cpu-quota` to limit the container's CPU usage. The unit is microseconds (default: `100000` microseconds = 100ms). \\n --cpu-quota: Sets the maximum amount of CPU time the container can use per period. The unit is microseconds. Must be used in conjunction with `--cpu-period`. \\n--blkio-weight: Sets the block I/O weight (range: `10` to `1000`), indicating the container's priority for disk I/O operations. The default value is `500`. \\n --pids-limit: Sets the maximum number of processes the container can use.\\n \\n --restart: Set the container restart policy (`no`, `on-failure`, `always`, `unless-stopped`).\\n \\n \\n
\\n \\n \\n
--
\\n \\nDocker Tutorial
\\n- \\n
- Docker Tutorial \\n
- Docker Concepts \\n
- Docker Architecture \\n
Contents
\\n- \\n
- Docker Installation \\n
- Docker Usage \\n
- Docker Examples \\n
- Docker Reference \\n
Docker Installation
\\n \\nDocker Usage
\\ndocker update CONTAINER [CONTAINER...]Common Parameters
\\n- \\n
- CONTAINER: The container name or container ID for which to update resource limits. You can specify one or more containers. \\n
- OPTIONS: Used to specify the resource limits that need to be updated. \\n
Common Options OPTIONS:
\\n- \\n
- --memory, -m: Set the memory limit for the container.\\n
- \\n
- Format: \\n
\\n
<size>[<unit>]\\n 500mγ2g etc.docker update -m 2g my_container\\n - \\n
- Format:
<size>[<unit>]οΌsuch as2gοΌor `-1` Means no limit. \\n
docker update --memory-swap 3g my_container- \\n
- This option does not directly limit the CPU usage of the container, but controls the priority of CPU resource allocation. \\n
docker update --cpu-shares 2048 my_container- \\n
- Format:
<number>, for example: `1.5` indicates a maximum usage of 1.5 CPU cores. \\n
docker update --cpus 2 my_containerdocker update --cpu-period 50000 my_containerdocker update --cpu-quota 25000 my_containerdocker update --blkio-weight 800 my_container- \\n
- Format:
<number>οΌFor example:`100`γ \\n
docker update --pids-limit 200 my_containerdocker update --restart always my_containerExample
\\n- \\n
- Update the container's memory limit:
This command updates the memory limit of my_container to 2GB.\\ndocker update -m 2g my_container\\n - Set CPU core limit:\\n
This command limits my_container to a maximum of 1.5 CPU cores.\\ndocker update --cpus 1.5 my_container\\n - Update the container's CPU weight:
This command sets the container's CPU weight to 1024, which is the default value.\\ndocker update --cpu-shares 1024 my_container\\n - Update the container's block I/O weight:
This command sets the container's disk I/O weight to 700, with the weight ranging from 10 to 1000.\\ndocker update --blkio-weight 700 my_container\\n
Limitations
\\n- \\n
- The `docker update` command takes effect immediately, but it does not affect the applications running inside the container; the container continues to run. \\n
- It only supports adjusting the container's resource limits and cannot modify other container configurations (such as environment variables, port mappings, etc.). \\n
YouTip