In this article I will describe how create an docker cluster for JMeter load/performance test.

You can test your speed with JMeter

What is JMeter?

The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

JMeter is a little old application for testing applications. There is new solutions with more interesting outputs, but you will not find so much functionalities there than you can find using JMeter. Gatling is good, but it is difficult to find good examples and tutorials

You can use JMeter to stress your application discovering which point of your application cannot scale.

In this very small tutorial, I will not focus on how create a JMeter test plan. The test plan that I will use only request a HTTP GET on And I will build a Master-Slave solution. The master will knows the test plan, and will send the execution plan to all the slaves. All slaves will execute the same test plan.

Master-Slave architecture

What is Docker?

Docker is different from a virtual machine because dockers containers shares pieces of the Guest OS, so it is lighter than a Virtual Machine.

With docker you can have more machines in the same infrastructure with less memory, and scale faster that using VMs.


  • Docker installed
  • Docker compose installed

Docker is easy to install in Linux. It is a little more complicated in MacOS. If you are using Windows, sorry…

Let’s start…

Creating a JMeter docker images

The Dockerfile bellow is my base JMeter image.

To use this image, create a folder named jmeter-base and save this Dockerfile inside, the execute: docker build -t jmeter-base ./jmeter-base. You will not execute this image, there is no CMD or ENTRYOPOINT in the image.

Now we should create more two folders jmeter-master and jmeter-slave.

This Dockerfile should be added inside jmeter-master folder
This Dockerfile should be added inside jmeter-slave folder

Now let’s create a docker-compose file to describe our environment.

OK, we have our environment describe in files. How we start it?

The script bellow (re)creates the jmeter-base image, start our environment, and scale the slaves machines.

Just execute ./ 10 to have 1 master and 10 slaves machines.

Starting the test…

The script bellow, we find all docker slaves IPs (line 1). Then for each *.jmx file inside a scripts directory we execute it using all jmeter-slave machines.

The main line at this script is the line 8. In this line we execute jmeter informing all slaves IPs: ./jmeter -n -t <test plan .jmx file> -R<list of slave IPs>

All the results are copied from the containers to the local machine.

Clean up…

Possible Improvements

  • Create test plans for each service of your system.
  • Use CLIChart to create graphs and build a report.
  • Create a better test plan to stress the system and get the response time for each situation.
  • Use the response time to know how your system scales.
  • Create a Docker swarm using the AWS infrastructure or Google Cloud.

Senior Software Engineer@Openet | Java | Software Architect | Technology | Society