# docker --version Docker version 1.10.3, build f476348/1.10.3 以1.10.3这个版本为例,其中跟cgroup 相关的option有以下几个:
--blkio-weight Block IO (relative weight), between 10 and 1000 --blkio-weight-device=[] Block IO weight (relative device weight) --cpu-shares CPU shares (relative weight) --cpu-period Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota Limit CPU CFS (Completely Fair Scheduler) quota --cpuset-cpus CPUs in which to allow execution (0-3, 0,1) --cpuset-mems MEMs in which to allow execution (0-3, 0,1) --device-read-bps=[] Limit read rate (bytes per second) from a device --device-read-iops=[] Limit read rate (IO per second) from a device --device-write-bps=[] Limit write rate (bytes per second) to a device --device-write-iops=[] Limit write rate (IO per second) to a device -m, --memory Memory limit --memory-reservation Memory soft limit --memory-swap Swap limit equal to memory plus swap: '-1' to enable unlimited swap --oom-kill-disable Disable OOM Killer
cgroup 子系统 blkio是用来限制block I/O 带宽docker
--blkio-weight --> 设置一个权重值,范围在100-1000之间,这跟cpu.shares 相似,是比重分配,而非拒绝的带宽限制,因此只有在不一样子系统在争夺带宽的子资源时候这个设定的值才生效bash
--blkio-weight-device=[] 是针对具体的设备设置权重值,这个值会覆盖 -blkio-weight的值 ex:利用cgroup 将/dev/sda 的权重设置成最小 #echo 8:0 100 > blkio.weight_device
CPU 子系统:ide
--cpu-shares 是分配cpu的比例权重,ex:512/1024 后者能够拿到2/3的cpu运行时间,固然也是当存在争夺的时候此分配的值才会生效,通常状况下是不工做的。 --cpu-period / --cpu-quota 这两个option通常是组合使用,能够利用 --cpu-period 设置成1秒,而后将--cpu-quota 设置为0.5秒,那么在cgroup中的进程在1秒内最多运行0.5秒,而后会被强制睡眠,直到进入下一个1秒时间片断 --cpuset-cpus 容许使用CPU的列表, 例如:0-3,10 (主要看server上的CPU数目和core的数目,lscpu能够查看) --cpuset-mems 容许进程使用的内存节点列表,例如 :0,1 主要手动利用cgroup 控制进程能够访问的内存节点,防止过多的跨内存使用CPU而减慢整个机器的运行速度
Device 子系统ui
--device-read-bps=[] 设置每秒读磁盘的带宽上限,须要指定设备 --device-read-iops=[] 设置每秒读磁盘的IOPS上限,须要指定设备 --device-write-bps=[] 设置每秒写磁盘的带宽上限,须要指定设备 --device-write-iops=[] 设置每秒写磁盘的IOPS上限,须要指定设备
-m, --memory 限制cgroup控制的进程使用memroy的上限,hard limit (绝对不会超过此值) --memory-reservation soft limit memory 使用,能够超过这个值 --memory-swap 限制cgroup控制的进程使用的swap memory的大小,其中此选项所对应的值是 memory + swarp 的和
--oom-kill-disable 打开此开关,那么当进程使用的memory超多的hard limit所限制的内存数目,那么会触发系统的OOM 而后杀掉某一个进程(通常是内存使用最多的进程)