Azure DevOps | Running JMeter Test Collection using JMeter Docker Image

Running JMeter Test Collection using JMeter Docker Image

JMeter is a popular open-source tool for performance testing and load testing of web applications. Running JMeter tests using Docker is a convenient way to ensure consistency and isolation. In this guide, we’ll show you how to run a JMeter test collection using a JMeter Docker image.


Before you begin, ensure that you have the following prerequisites:

  • Docker installed on your machine.


  1. Pull the JMeter Docker Image:

    You can pull the official JMeter Docker image from Docker Hub:

    docker pull justb4/jmeter:latest

    This will download the latest JMeter Docker image to your local machine.

  2. Prepare Your JMeter Test Collection:

    Create a directory that contains your JMeter test plan files (.jmx). You can organize your collection of test plans in this directory.

  3. Run JMeter Tests using the Docker Image:

    You can run your JMeter test collection by mounting the test plan directory to the Docker container and specifying the JMX file to execute.

    Replace YOUR_TEST_DIRECTORY and YOUR_TEST_FILE.jmx with your actual test directory and JMX file.

    docker run -it --rm -v /path/to/YOUR_TEST_DIRECTORY:/mnt/jmeter -w /mnt/jmeter justb4/jmeter -n -t /mnt/jmeter/YOUR_TEST_FILE.jmx
    • -it - Runs the container in interactive mode.
    • --rm - Removes the container when it stops.
    • -v /path/to/YOUR_TEST_DIRECTORY:/mnt/jmeter - Mounts your test directory to the container at /mnt/jmeter.
    • -w /mnt/jmeter - Sets the working directory to /mnt/jmeter within the container.
    • justb4/jmeter - Specifies the JMeter Docker image.
    • -n - Runs JMeter in non-GUI mode.
    • -t /mnt/jmeter/YOUR_TEST_FILE.jmx - Specifies the JMX file to execute.
  4. View Test Results:

    After the test is completed, you can view the results in the console output. You can also configure JMeter to save the test results in various formats, such as CSV or XML, by adding appropriate listeners to your JMX file.

What Next?

Running JMeter test collections using a Docker image simplifies the setup and execution process, making it easier to perform load testing and performance testing on your web applications. You can easily automate and integrate this process into your CI/CD pipelines for continuous performance monitoring. Remember to replace YOUR_TEST_DIRECTORY and YOUR_TEST_FILE.jmx with your actual test collection directory and JMX file, and customize any additional parameters as needed for your specific testing requirements.

This post is licensed under CC BY 4.0 by the author.