首页 > 其他 > 详细

8.docker的系统资源限制

时间:2019-10-22 21:54:40      阅读:119      评论:0      收藏:0      [点我收藏+]

一、 概述

默认docker容器使用的memory资源和CPU资源是没有限制的,但是我们可以在docker run的时候通过选项去限制,具体参考官方文档。

[root@node1 ~]# docker run --help
    --kernel-memory bytes            Kernel memory limit
-m, --memory bytes                   Memory limit
    --memory-reservation bytes       Memory soft limit
    --memory-swap bytes              Swap limit equal to memory plus swap: -1 to enable unlimited swap
    --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
    --oom-kill-disable         Disable OOM Killer 
   --oom-score-adj int              Tune host‘s OOM preferences (-1000 to 1000)
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota --cpu-rt-period int Limit CPU real-time period in microseconds --cpu-rt-runtime int Limit CPU real-time runtime in microseconds -c, --cpu-shares int CPU shares (relative weight) --cpus decimal Number of CPUs --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1)

技术分享图片

 操作系统进程管理子系统中,最重要的组件之一,进程调度器(scheduler)。docker1.13以前版本配置使用CFS scheduler(Completely Fair Scheduler 完全公平调度器),在docker1.13及以后版本,也可以使用realtime scheduler。

进程:CPU密集型,IO密集型。

Tips:尽量不要以管理员账号运行容器,并且应该做好资源限制。

二、示例

[root@node1 ~]# docker pull lorel/docker-stress-ng  #压测工具
[root@node1 ~]# docker run --name stress --rm lorel/docker-stress-ng:latest stess --help #查看工具的帮助
[root@node1 ~]# docker run --name stress --rm -m 256m  lorel/docker-stress-ng:latest stess --help :latest stess --vm 2  #压测内存
[root@node1 ~]# docker top stress  #查看stress容器内运行进程的资源使用情况
[root@node1 ~]# docker stats    # 查看所有容器资源使用的动态变化
[root@node1 ~]# docker run --name stress --rm --cpus 0.5  lorel/docker-stress-ng:latest stess --cpu 4  #压测从CPU
[root@node1 ~]# docker top stress
[root@node1 ~]# docker stats

 

8.docker的系统资源限制

原文:https://www.cnblogs.com/cmxu/p/11695329.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!