首页 技术 正文
技术 2022年11月15日
0 收藏 832 点赞 4,251 浏览 979 个字

最近需要学习docker的Cgroups机制,需要用到stress进行测试,前期工作就是自己创建一个stress镜像。

  1. 新建一个 Dockerfile 文件

    [vagrant@localhost ~]$ mkdir -p /tmp/stress
    [vagrant@localhost stress]$ sudo vi Dockerfile
    FROM library/centosADD epel-7.repo /etc/yum.repos.d/
    RUN yum clean all && yum makecache
    RUN yum install -y stress
    #CMD与ENTRYPOINT的区别在于执行docker run时参数传递的方式不同
    ENTRYPOINT ["stress", "--verbose"]

      

  2. 构建镜像
    [vagrant@localhost stress]$ docker build -t centos-stress:1.0.1 .
  3. 查看镜像是否生成
    [vagrant@localhost stress]$ docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    centos-stress 1.0.1 3dd149b42c38 25 minutes ago 713MB

      

  4. 测试改镜像成功
    [vagrant@localhost cgroup]$ docker run -ti --rm -m 200M --memory-swap=300M centos-stress:1.0.1 --vm 1 --vm-bytes 280M
    stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    stress: dbug: [1] using backoff sleep of 3000us
    stress: dbug: [1] --> hogvm worker 1 [5] forked
    stress: dbug: [5] allocating 293601280 bytes ...
    stress: dbug: [5] touching bytes in strides of 4096 bytes ...
    stress: dbug: [5] freed 293601280 bytes
    stress: dbug: [5] allocating 293601280 bytes ...
    stress: dbug: [5] touching bytes in strides of 4096 bytes ...

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,490
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,905
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,738
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,491
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,129
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,292