基于centos 创建stress镜像——源码安装stress

上一篇文章进行了yum安装stress,这次对stress进行源码编译安装,并且生成新的镜像

 

  1. 创建Dockerfile目录
    [vagrant@localhost ~]$ mkdir -p /tmp/stress
    [vagrant@localhost stress]$ sudo vi Dockerfile                                            
    FROM library/centos
    
    ADD Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo
    ADD stress-1.0.4.tar.gz  /usr/local/src
    RUN yum clean all && yum makecache && yum install -y make automake autoconf gcc gcc-c++
    WORKDIR /usr/local/src/stress-1.0.4
    RUN ./configure --prefix=/usr/local/stress
    RUN make && make install
    ENV PATH /usr/local/stress/bin:$PATH
    #CMD与ENTRYPOINT的区别在于执行docker run时参数传递的方式不同
    ENTRYPOINT ["stress", "--verbose"]

     

  2. 根据Dockerfile生成创建一个stress镜像
    docker build -t centos-stress-source:1.0.2 .
  3. 查看镜像 
    [vagrant@localhost stress]$ docker images
    REPOSITORY                                       TAG                 IMAGE ID            CREATED             SIZE
    centos-stress-source                             1.0.2               4f8b1ae5f7e8        7 minutes ago       546MB

     

  4. 测试是否可用
    [vagrant@localhost stress]$ docker run -ti --rm -m 200M --memory-swap=300M centos-stress-source:1.0.2 --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 ...
posted @ 2018-02-26 14:26  我为什么要写这个  阅读(721)  评论(0编辑  收藏  举报