How to Build a Scalable JMeter Distributed Load Test with Docker
This guide explains how to use Docker containers to create a JMeter master‑slave distributed testing environment, covering required ports, Dockerfile configurations for base, master, and slave images, container deployment commands, and running tests both locally and across multiple Dockerized JMeter slaves.
A single JMeter instance may not generate enough load for stress testing; using a master JMeter instance to control many remote JMeter slaves via Java RMI enables larger loads. The master and slave communication requires opening ports 1099, 50000 (server) and 60000 (client).
Docker simplifies this setup by packaging a consistent Java 8, JMeter, and required plugins into containers, ensuring identical environments across all machines.
Dockerfile for the base JMeter image (jmbase)
# Use Java 8 slim JRE
FROM openjdk:8-jre-slim
MAINTAINER TestAutomationGuru
# JMeter version
ARG JMETER_VERSION=3.3
# Install utilities
RUN apt-get clean && \
apt-get update && \
apt-get -qy install \
wget \
telnet \
iputils-ping \
unzip
# Install JMeter
RUN mkdir /jmeter \
&& cd /jmeter/ \
&& wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz \
&& tar -xzf apache-jmeter-${JMETER_VERSION}.tgz \
&& rm apache-jmeter-${JMETER_VERSION}.tgz
# Add plugins
ADD jmeter-plugins/lib /jmeter/apache-jmeter-${JMETER_VERSION}/lib
# Add sample test
ADD sample-test sample-test
# Set JMeter Home
ENV JMETER_HOME /jmeter/apache-jmeter-$JMETER_VERSION/
# Add JMeter to the Path
ENV PATH $JMETER_HOME/bin:$PATHDockerfile for the JMeter master
# Use vinsdocker base image
FROM vinsdocker/jmbase
MAINTAINER TestAutomationGuru
# Ports to be exposed from the container for JMeter Master
EXPOSE 60000Dockerfile for JMeter server/slave
# Use vinsdocker base image
FROM vinsdocker/jmbase
MAINTAINER TestAutomationGuru
# Ports to be exposed from the container for JMeter Slaves/Server
EXPOSE 1099 50000
# Application to run on starting the container
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \
-Dserver.rmi.localport=50000 \
-Dserver_port=1099After building and pushing these images to Docker Hub, you can launch containers:
sudo docker run -dit --name slave01 vinsdocker/jmserver /bin/bash
sudo docker run -dit --name slave02 vinsdocker/jmserver /bin/bash
sudo docker run -dit --name slave03 vinsdocker/jmserver /bin/bash
sudo docker run -dit --name master vinsdocker/jmmaster /bin/bashList running containers and obtain their IP addresses with:
sudo docker ps -a
sudo docker inspect --format '{{ .Name }} => {{ .NetworkSettings.IPAddress }}' $(sudo docker ps -a -q)Copy test files into the master container:
sudo docker exec -i master sh -c 'cat > /jmeter/apache-jmeter-3.3/bin/docker-test.jmx' < docker-test.jmxRun a local test inside the master container: jmeter -n -t sample-test/sample-test.jmx Run a distributed test across the slaves (replace IPs with the ones obtained earlier):
jmeter -n -t sample-test/sample-test.jmx -R172.17.0.5,172.17.0.6,172.17.0.7Images illustrating the architecture and container status:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
