最终方案三:
FROM openjdk:8-jdk
ENV JMETER_VERSION 5.1.1
ENV JMETER_HOME /usr/local/apache-jmeter-{JMETER_HOME}/bin:${PATH}
ENV http_proxy ""
ENV https_proxy ""
RUN apt-get -y update &&
apt-get -y install wget
RUN wget [http://mirrors.tuna.tsinghua.edu.cn/apache/jmeter/binaries/apache-jmeter-%7BJMETER_VERSION%7D.tgz) &&
tar -xzf apache-jmeter-${JMETER_VERSION}.tgz -C /usr/local/
RUN rm -rf apache-jmeter-{JMETER_HOME}/bin/examples
{JMETER_HOME}/bin/.cmd
{JMETER_HOME}/docs
${JMETER_HOME}/printable_docs &&
apt-get -y remove wget &&
apt-get -y --purge autoremove &&
apt-get -y clean &&
rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*
WORKDIR /usr/local/apache-jmeter-5.1.1/bin/
CMD ["/bin/bash","-c","${JMETER_HOME}/bin/jmeter-server -Dserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=172.16.222.128 -Dserver.rmi.localport=1099 -Dserver_port=1099"]
启动命令
主机模式启动,cmd参数带入
例子:
docker run -it --name=jmeter-1099 --net=host jmeter:v01 jmeter-server -D server.rmi.ssl.disable=true -LDEBUG -Djava.rmi.server.hostname=192.168.40.134 -Dserver.rmi.localport=1099 -Dserver_port=1099 -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -Djava.net.preferIPv6Addresses=false
-D 参数启动设定带设定参数,如果不带入默认参数jmeter.properties
查看日志
docker logs
例子:
docker logs --tail=10 -f 容器id
重启容器:
docker restart 容器id
重启启动dockerdeam
systemctl start docker.service
进入相应的容器
docker exec -it 容器id sh