如何在dockerfile中使用volume来复制我本地的jmeter结果

时间:2018-05-08 12:47:53

标签: docker jmeter docker-compose dockerfile

如何在dockerfile中使用volume来复制本地的JMeter结果? 需要在本地显示结果,如何在VOLUME的帮助下复制结果并粘贴到本地。

例如: - 我正在我的容器中保存JMeter HTML报告,但在该容器自动停止之后。所以有人建议我使用docker VOLUME命令来运行HTML。

FROM alpine

ARG JMETER_VERSION="4.0"
ENV JMETER_HOME /opt/apache-jmeter-${JMETER_VERSION}
ENV JMETER_BIN  ${JMETER_HOME}/bin
ENV JMETER_DOWNLOAD_URL  https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz
ENV JMETER_PLUGINS_DOWNLOAD_URL http://repo1.maven.org/maven2/kg/apc/jmeter-plugins-functions/2.0/jmeter-plugins-functions-2.0.jar
ENV JMETER_PLUGINS_FOLDER ${JMETER_HOME}/lib/ext/


# Change TimeZone TODO: TZ still is not set!
ARG TZ="Australia/Melbourne"
RUN    apk update \
    && apk upgrade \
    && apk add ca-certificates \
    && update-ca-certificates \
    && apk add --update openjdk8-jre tzdata curl unzip bash \
    && rm -rf /var/cache/apk/* \
    && mkdir -p /tmp/dependencies  \
    && curl -L --silent ${JMETER_DOWNLOAD_URL} >  /tmp/dependencies/apache-jmeter-${JMETER_VERSION}.tgz  \
    && mkdir -p /opt  \
    && tar -xzf /tmp/dependencies/apache-jmeter-${JMETER_VERSION}.tgz -C /opt  \
    && rm -rf /tmp/dependencies

RUN curl -L --silent ${JMETER_PLUGINS_DOWNLOAD_URL}/jmeter-plugins-dummy/0.2/jmeter-plugins-dummy-0.2.jar -o ${JMETER_PLUGINS_FOLDER}/jmeter-plugins-dummy-0.2.jar
RUN curl -L --silent ${JMETER_PLUGINS_DOWNLOAD_URL}/jmeter-plugins-cmn-jmeter/0.5/jmeter-plugins-cmn-jmeter-0.5.jar -o ${JMETER_PLUGINS_FOLDER}/jmeter-plugins-cmn-jmeter-0.5.jar

# TODO: plugins (later)
# && unzip -oq "/tmp/dependencies/JMeterPlugins-*.zip" -d $JMETER_HOME

# Set global PATH such that "jmeter" command is found
ENV PATH $PATH:$JMETER_BIN

ENV URL_PATH=${URL}

WORKDIR ${JMETER_HOME} 

#RUN export DATETIME=$(date +%Y%m%d)

RUN mkdir -p /var/www/html/"$(date +%Y%m%d)"

VOLUME /var/www/html/

#Copy the *.jmx file jmeter bin file 
COPY Get_Ping_Node_API.jmx ./bin

CMD ./bin/jmeter -n -t ./bin/Get_Ping_Node_API.jmx -l ./bin/result.jtl -e -o ./bin/result_html'

1 个答案:

答案 0 :(得分:0)

您可以在运行泊坞窗图像时使用泊坞窗卷。 您可以在docker run命令中添加--volume,-v标志。

  

docker run -v“HOST DIR”:“CONTAINER DIR”