Search code examples
dockerjmeterload-testingjmx

Trying to run a JMeter test using a docker container for JMeter (non GUI mode) throws error "Could not open xxxx.jmx file"


I am trying to distribute loading tests using Docker containers.

At local in JMeter, my tests run correctly in GUI or non GUI mode, but when I try to run any of them in non GUI mode using a docker image for JMeter:

docker run egaillardon/jmeter -n -t ~/Developer/testing/login_test.jmx -l ~/Desktop/resultado.jtl

I get the error:

Could not open ~/Developer/testing/login_test.jmx

I tried with different docker images for JMeter (egaillardon/jmeter, justb4/jmeter, vmarrazzo/jmeter) and I got the same error in any of them. Anyone knows what I have to change in my jmx file to do it readable?

I already tried with this solution in Stack Exchange but none worked for me.


Solution

  • ~/Developer/testing/login_test.jmx would be loaded from the container filesystem perpective, chances are that this path does not exist within your container filesystem.

    To overcome this, you could mount this file from your host filesystem into your container filesystem with a docker volume:

    docker run -v ~/Developer/testing/:/workspace egaillardon/jmeter -n -t /workspace/login_test.jmx -l /workspace/resultado.jtl
    

    Explanations

    • -v ~/Developer/testing/:/workspace: mount the ~/Developer/testing/ directory from your host to the path /workspace/ in the container filesystem
    • -n -t /workspace/login_test.jmx -l /workspace/resultado.jtl: options passed to the container processus (jmeter) at runtime, and thus in the context of the container. We need to adjust paths so that they match the location we chose when configuring the volume.