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 ...
随机推荐
- day40--mysql step4 SQLAlchemy
1.unique = True 表示启动唯一索 2.有add 必须有commit这样数据才会提交 3.ORM功能 #!/usr/bin/env python # -*- coding:utf-8 -* ...
- loadrunner11使用wplus_init_wsock录制非IE脚本/手机抓包
假如你的IE版本号太高,或者是chrome,firfox,又或者想录手机上的包,可以用loadrunner的wplus_init_wsock工具 1.在创建LR脚本的Start Recording ...
- Python学习-day10(番外篇) 阻塞IO 非阻塞IO 同步IO 异步IO
这个章节的内容是关于IO的概念,谈一谈什么是 阻塞IO 非阻塞IO 同步IO 异步IO.以下摘要是我对这四种IO的一个形象理解. 场景是去去银行办理业务.节点有三个,1)到银行提交申请:2)取号:3) ...
- backpropagation算法示例
backpropagation算法示例 下面举个例子,假设在某个mini-batch的有样本X和标签Y,其中\(X\in R^{m\times 2}, Y\in R^{m\times 1}\),现在有 ...
- Visual C++网络五子棋游戏源代码
说明:网络对战版的五子棋,VC++游戏源码,带音乐,可设置网络最终网络下棋,通过源代码你将了解到设置菜单状态.服务器端口申请.客户机申请连接.发送数据.游戏编写.监听和使用套接字.主菜单对象定义等基础 ...
- 聊聊、Integer 封装特性
前几天在公司内部群,有人分享出了一道题,问谁能口算出来,他就膜拜那个人.题目如下: Class cache = Integer.class.getDeclaredClasses()[0]: Field ...
- 深入学习之mysql(三)单表操作
1.创建表的结构和数据 CREATE TABLE `t_student`( `id` INT PRIMARY KEY, `stuName` VARCHAR(10) NOT NULL, `age` IN ...
- 【转】unity自带寻路Navmesh入门教程(一)
http://liweizhaolili.blog.163.com/blog/static/16230744201271161310135/ 说明:从今天开始,我阿赵打算写一些简单的教程,方便自己日后 ...
- jquery对象与js对象
对于已经是一个 DOM 对象,只需要用 $() 把DOM对象包装起来,就可以获得一个 jQuery 对象了,使用[index]和.get(index)可以转为DOM对象 jQuery 对象是通过 jQ ...
- linux 相关知识
在mac 终端中可以直接访问ssh 命令:ssh root@127.0.0.* 批量删除文件: 当前目录下所有 *.html文件,除了index.html [root@whr ...