国王陛下万万岁

导航

 

网上多是创建docker镜像是从jmeter官方下载jmeter的tgz包

今天我们用本地已经下载好的tgz包。

以下是dockerfile

FROM java:8

ENV http_proxy ""
ENV https_proxy ""

RUN mkdir /jmeter
RUN cd /jmeter

ENV JMETER_VERSION=5.1.1
ENV JMETER_HOME=/jmeter/apache-jmeter-${JMETER_VERSION}
ENV JMETER_PATH=${JMETER_HOME}/bin:${PATH}

COPY apache-jmeter-5.1.1.tgz /jmeter

RUN cd /jmeter \
    && tar xvf apache-jmeter-5.1.1.tgz \
    && rm apache-jmeter-5.1.1.tgz

 

经过一些修改优化过的Dockerfile

FROM java:8

ENV http_proxy ""
ENV https_proxy ""

RUN mkdir /jmeterdocker
RUN mkdir -p /jmeterdocker/test
RUN mkdir -p /jmeterdocker/test/input/jmx
RUN mkdir -p /jmeterdocker/test/input/testdata
RUN mkdir -p /jmeterdocker/test/report/html
RUN mkdir -p /jmeterdocker/test/report/jtl
RUN mkdir -p /jmeterdocker/test/report/outputdata
RUN chmod -R 777 /jmeterdocker

ENV JMETER_VERSION=5.1.1
ENV JMETER_HOME=/jmeterdocker/apache-jmeter-${JMETER_VERSION}
ENV JMETER_PATH=${JMETER_HOME}/bin:${PATH}
ENV PATH=${JMETER_HOME}/bin:${PATH}

COPY apache-jmeter-5.1.1.tgz /jmeterdocker

RUN cd /jmeterdocker \
    && tar xvf apache-jmeter-5.1.1.tgz \
    && rm apache-jmeter-5.1.1.tgz

 

Dockered Jmeter自定义的一些目录结构

file directory in docker
/jmeterdocker
/jmeterdocker/test
/jmeterdocker/test/input/jmx #jmx测试脚本
/jmeterdocker/test/input/testdata #jmeter的测试数据
/jmeterdocker/test/report/html #jmeter生成的html报告
/jmeterdocker/test/report/jtl #jmeter生成的jtl报告
/jmeterdocker/test/report/outputdata #jmeter生成的csv文件,某些测试用例会生成csv数据文件,这些数据文件会被其它测试用例使用

file directory in host 参照file directory in docker设置即可

 

启动dockered jmeter容器

docker run --name="jmeter1" --net="host" -v /tmp/jmeterspace/test/input/jmx:/jmeterdocker/test/input/jmx \
            -v /tmp/jmeterspace/test/input/testdata:/jmeterdocker/test/input/testdata \
            -v /tmp/jmeterspace/test/report/html:/jmeterdocker/test/report/html \
            -v /tmp/jmeterspace/test/report/jtl:/jmeterdocker/test/report/jtl \
            -v /tmp/jmeterspace/test/report/outputputdata:/jmeterdocker/test/report/outputdata \
            -it -d galaxi/jmeter:v1.1

 docker 存在下载镜像时,最后几兆死活下载不过来的问题

posted on 2019-04-21 15:18  国王陛下万万岁  阅读(3832)  评论(0编辑  收藏  举报