Requirements: When creating a docker container, you can limit the maximum memory usage of the container by adding the -m parameter.
Review container memory limits
The host machine installs an 8G memory stick and creates 3 containers, of which the maximum memory of the itsvse-redis container is limited to 512M, and the remaining two containers are not restricted, as shown in the figure below:
Detailed explanation of output information format
[CONTAINER]: Displays the container's ID in a short form. CPU %: CPU usage. [MEM USAGE/LIMIT]: The memory currently used and the maximum memory that can be used. [MEM %]: Displays memory usage as a percentage. [NET I/O]: Network I/O data. [BLOCK I/O]: Disk I/O data. [PIDS]:P ID number.
Docker update command
The docker update command dynamically updates the container configuration. You can use this command to prevent containers from consuming too many resources from their Docker hosts. With a single command, you can set limits on a single container or multiple containers. To specify multiple containers, provide a list of container names or IDs separated by spaces.
OPTIONS Description
name | description | --blkio-weight | Blocking IO (relative weight), between 10 and 1000, 0 is disabled (default suppressed) | --cpu-period | Limit CPU CFS (Totally Fair Scheduler) duration | --cpu-quota | Limit CPU CFS (Completely Fair Scheduler) quotas | --cpu-rt-period | API 1.25+, which limits CPU real-time time to microseconds | --cpu-rt-runtime | API 1.25+, which limits CPU real-time runtime to microseconds | --cpu-shares, -c | CPU share (relative weight) | --cpus | API 1.29+, number of CPUs | --cpuset-cpus | Allowed CPU (0-3,0,1) | --cpuset-mem | Allowed MEM (0-3,0,1) | --kernel-memory | Kernel memory limits | --memory-swap | The swap limit is equal to memory plus swapping, "-1" to enable unlimited swapping | --memory-reservatio | Memory soft limit | --memory, -m | Memory limit | --pids-limit | API 1.40+, adjust container pids limits (-1 means unlimited) | --restart | Restart the policy to apply when the container exits |
Documentation:The hyperlink login is visible.
Suppose you limit the php5-fpm containerMaximum memory usage 1024M (1G), the command is as follows:
(End)
|