用dockerfile创建jmeter的docker镜像

网上多是创建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:

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 /jmeterdocker ENV JMETER_VERSION=5.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..tgz /jmeterdocker RUN cd /jmeterdocker \
&& tar xvf apache-jmeter-5.1..tgz \
&& rm apache-jmeter-5.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.

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

用dockerfile创建jmeter的docker镜像

上一篇:nova系列二:kvm介绍


下一篇:【一天一道LeetCode】#61. Rotate List