Docker 限制容器资源
| 选项 | 说明 |
-m or --memory= |
容器能使用的最大的内存。
如果你设置了这个选项,最小允许使用的值为4M。
|
--memory-swap* |
容器允许swap的内存大小。
更多细节:
--memory-swap details. |
--memory-swappiness |
默认情况下,不需要设置。
主机内核可以让容器使用一定比例的匿名内存页。你可以通过这个参数来设置这个百分比。更多细节:
--memory-swappiness details. |
--memory-reservation |
允许你指定软限制,比--memory 参数值要小。这软限制在Docker检测到主机上的连接或内存较少时激活。 |
--kernel-memory |
容器可以使用的最大的内核内存。最小值是4M。 因为内核内存不能被交换出去,一个缺少内核内存的容器可能会阻碍主机的资源,这会对主机和其他容器产生负面影响。
更多细节:
--kernel-memory details. |
--oom-kill-disable |
默认情况下:out-of-memory(oom)内存溢出的错误出现,内核杀死容器中的进程。使用--oom-kill-disable 可以改变这种行为。 仅仅在已经设置了-m 的容器中关闭 OOM 杀死。 如果-m 标志没有设置,主机可能耗尽内存,内核可能需要杀死主机系统进程来释放内存。 |
- 如果没有设置,而--me内核内存限制以分配给容器的总内存来表示。mory设置如300m了,则swap默认为300*2=600M
- 如果--memory,--memory-swap都设置了
- --memory-swap 代表了可以使用的总共内存,--memory 代表不使用swap的内存
- 如:--memory-swap=1g,--memory=300M,
- docker可以使用300M内存,1g-300m=700m swap.
- 如果设置为-1,则容器不限制使用swap 内存。
| Option | Description |
|---|---|
--cpu-shares |
Set this flag to a value greater or less than the default of 1024 to increase or reduce the container’s weight, and give it access to a greater or lesser proportion of the host machine’s CPU cycles. This is only enforced when CPU cycles are constrained. When plenty of CPU cycles are available, all containers use as much CPU as they need. In that way, this is a soft limit. --cpu-sharesdoes not prevent containers from being scheduled in swarm mode. It prioritizes container CPU resources for the available CPU cycles. It does not guarantee or reserve any specific CPU access. |
--cpu-period |
容器上一个逻辑CPU的调度周期. --cpu-periodmor默认值是100000(100ms) |
--cpu-quota |
在由--cpu-period设置的时间段内容器可以调度的最大时间量。 |
--cpuset-cpus |
使用这个选项指定CPU使用一个或者多个CPU核,并用逗号分隔。 |
$ docker run -ti --cpu-period= --cpu-quota= busybox
$ docker run -ti --cpu-period= --cpu-quota=
$ docker run -ti --cpuset-cpus= busybox
| Option | Description |
|---|---|
blkio-weight |
By default, each container can use the same proportion of block IO bandwidth (blkio). The default weight is 500. To raise or lower the proportion of blkio used by a given container, set the --blkio-weight flag to a value between 10 and 1000. This setting affects all block IO devices equally. |
blkio-weight-device |
The same as --blkio-weight, but you can set a weight per device, using the syntax --blkio-weight-device="DEVICE_NAME:WEIGHT" The DEVICE_NAME:WEIGHT is a string containing a colon-separated device name and weight. |
--device-read-bps and--device-write-bps |
Limits the read or write rate to or from a device by size, using a suffix of kb, mb, or gb. |
--device-read-iops or--device-write-iops |
Limits the read or write rate to or from a device by IO operations per second. |
$ docker run -it \
--blkio-weight-device "/dev/sda:200" \
ubuntu
$ docker run -ti --device-read-iops /dev/sda: ubuntu
- 默认容器没有资源的限制,Docker提供了控制方法;
- 内存,CPU,IO
- docker run + 标志符来设置
- 主要参数
- 内存
- -m 容器能使用的最大内存
- --memory--reservation
- 比-m的值要小,在docker检测到主机的内存较少时激活
- CPU
- --cpu-period, --cpu-quota
- 允许容器使用50%的CPU
- --cpu-period = 10 ,--cpu-quota=5
- 允许容器使用主机4核中的两核
- --cpu-period = 10 , --cpu-quota=20
- IO
- 控制每秒的字节数或每秒的IO操作来限制带宽
- 限制从/dev/sda 每秒1000次的IO读取操作
- docker run -ti --device-read-iops /dev/sda:1000 ubuntu
- 内存
Docker 限制容器资源的更多相关文章
- Docker(十九)-Docker监控容器资源的占用情况
启动一个容器并限制资源 启动一个centos容器,限制其内存为1G ,可用cpu数为2 [root@localhost ~]# docker run --name os1 -it -m 1g --cp ...
- Docker监控容器资源的占用情况
启动一个容器并限制资源 启动一个centos容器,限制其内存为1G ,可用cpu数为2 [root@localhost ~]# docker run --name os1 -it -m 1g --cp ...
- docker网络-如何让外部网络访问容器资源
docker网络-如何让外部网络访问容器资源 安装httpd 服务: docker:/root# docker exec -it f63b2633d146 bash bash-4.1# yum ins ...
- Docker 容器资源限制
Docker 容器资源限制 默认情况下,一个容器并没有资源限制,并且该容器可以使用内核调度的所有资源.Docke提供了在启动容器时设置一些参数来控制该容器使用的内存.CPU和IO. 内存 OOME:在 ...
- docker容器资源配额控制
转自:http://blog.csdn.net/horsefoot/article/details/51731543 文/ 天云软件 容器技术团队 Docker通过cgroup来控制容器使用的资源配额 ...
- docker 限制容器能够使用的资源
docker 限制容器能够使用的内存,CPU,I/O 资源概述,内存是非可压缩资源,cpu是可压缩资源. 内存用超了,就发送Out Of Memory Exception,容器会被kill掉.所以内存 ...
- docker容器资源配额控制_转
转自:docker容器资源配额控制 ■ 文/ 天云软件 容器技术团队 docker通过cgroup来控制容器使用的资源配额,包括CPU.内存.磁盘三大方面,基本覆盖了常见的资源配额和使用量控制. cg ...
- Docker与容器快速入门
Docker之风席卷全球,但很多人觉得docker入门确实不太容易,其原因在于很多知识点上没准备好,在docker解决了什么问题.怎么解决的.用什么技术解决的都还没想清楚的时候就去探索docker组件 ...
- Docker系列之(三):Docker微容器Alpine Linux
1. 前言 使用Docker创建容器时,基础镜像通常选择Ubuntu或Centos,不管哪个镜像的大小都在100MB以上. Alpine Linux是一个面向安全的轻型的Linux发行版. Alpin ...
随机推荐
- ogre3D学习基础19 --- 材质的继承,纹理的滚动与旋转
以上一节为基础,废话不多说. 首先新增一个节点,用于比较显示 //新增一个节点 ent = mSceneMgr->createEntity("Quad"); ent-> ...
- oracle常用关键字和函数
数据库的增删改查: 增:insert into ... values(); 例:insert into p_emp values(sq_emp.nextval,,sysdate,,null,,); c ...
- java包、类、方法、属性、常量命名规则
必须用英文,不要用汉语拼音 1:包(package):用于将完成不同功能的类分门别类,放在不同的目录(包)下,包的命名规则:将公司域名反转作为包名.比如www.sohu.com 对于包名:每个字母都需 ...
- Callable、Future、FutureTask浅析
1.Callable<V>接口 Runnable接口 public interface Runnable { public abstract void run(); } Callable ...
- 【bzoj4836】[Lydsy2017年4月月赛]二元运算 分治+FFT
题目描述 定义二元运算 opt 满足 现在给定一个长为 n 的数列 a 和一个长为 m 的数列 b ,接下来有 q 次询问.每次询问给定一个数字 c 你需要求出有多少对 (i, j) 使得 a_ ...
- Newton 插值法
定义 $f(x)$ 关于 $x_0, x_1, \dots, x_k$ 的 $k$ 阶均差(差商)记做 $ f [x_0, x_1, \dots, x_k] $,均差是递归定义的,有两种等价定义 \b ...
- uvalive 6323 状态压缩DP
思路:dp[i][j][x]表示状态 i 以 j 为结束 得分为 x 的方案数. #include<iostream> #include<cstdio> #include< ...
- BZOJ3129 [Sdoi2013]方程 【扩展Lucas】
题目 给定方程 X1+X2+. +Xn=M 我们对第l..N1个变量进行一些限制: Xl < = A X2 < = A2 Xn1 < = An1 我们对第n1 + 1..n1+n2个 ...
- a:active在ios上无效解决方法
原因: By default, Safari Mobile does not use the :active state unless there is a touchstart event hand ...
- BZOJ3612 [Heoi2014]平衡 整数划分
[Heoi2014]平衡 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 348 Solved: 273[Submit][Status][Discus ...