To run JMeter in Docker, build an image with a Java runtime and the JMeter binary release, mount the folder that holds your .jmx file, and start JMeter in non-GUI mode as the container’s command. Apache does not publish an official image, so you either pick a community image or build your own; a Dockerfile takes about 15 lines.
We built one for JMeter 5.6.3 on Java 21, ran tests in it, squeezed it into a 512 MB container until it broke, and ran a distributed test with Docker Compose. Every command and number below comes from those runs or from the sources listed at the end.
Key Takeaways
- There is no official Apache JMeter image on Docker Hub. justb4/jmeter, one of the most pulled community images (24 million pulls), still tops out at JMeter 5.5 (last updated September 2022).
- A Dockerfile on
eclipse-temurin:21-jrethat downloads the release and checks its SHA-512 is enough. Our image came to 491 MB. - JMeter’s start script fixes the heap at 1 GB (
-Xms1g -Xmx1g) whatever memory the container has. In a 512 MB container with swap off, a plan that needed 700 MiB got JMeter killed: exit 137, an empty results file, no error in jmeter.log. SetHEAPyourself. - JMeter exits with code 0 even when every request failed or the JVM ran out of heap, so a CI job must read the results, not the exit code.
- In distributed mode every server runs the whole plan: 2 servers with a 10-thread, 20-loop plan sent 400 requests, not 200. Properties for the servers need
-G, not-J.
Is there an official JMeter Docker image?
No. Docker Hub has no apache/jmeter repository and no Docker Official Image for JMeter: hub.docker.com/r/apache/jmeter and the official-image path, library/jmeter, both return 404 (checked 3 December 2026). The Apache JMeter project ships zip and tgz archives with checksums, and leaves packaging to users. Community images fill the gap, and their age varies a lot, so check the tags before you depend on one.
Two widely used community images, read on Docker Hub on 3 December 2026:
| Image | Pulls | Newest JMeter tag | Last updated |
|---|---|---|---|
| justb4/jmeter | 24,359,608 | 5.5 | 29 September 2022 |
| alpine/jmeter | 752,779 | 5.6.3 | 28 November 2026 |
JMeter 5.6.3 has been the current release since January 2024, so the image with 24 million pulls is four releases behind (5.6, 5.6.1, 5.6.2 and 5.6.3). Building your own image avoids that question and lets you pin the Java version, the JMeter version and any plugins your plans need.
How do you build a JMeter Docker image?
Start from a Java runtime image, download the JMeter binary archive, verify it against the SHA-512 that Apache publishes, unpack it, put bin on the PATH and make jmeter the entrypoint so arguments pass straight through. This is the Dockerfile we used for every run in this article:
FROM eclipse-temurin:21-jre
ARG JMETER_VERSION=5.6.3
ARG JMETER_SHA512=5978a1a35edb5a7d428e270564ff49d2b1b257a65e17a759d259a9283fc17093e522fe46f474a043864aea6910683486340706d745fcdf3db1505fd71e689083
RUN curl -fsSL -o /tmp/jmeter.tgz \
"https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz" \
&& echo "${JMETER_SHA512} /tmp/jmeter.tgz" | sha512sum -c - \
&& tar -xzf /tmp/jmeter.tgz -C /opt \
&& rm /tmp/jmeter.tgz \
&& ln -s "/opt/apache-jmeter-${JMETER_VERSION}" /opt/jmeter
ENV PATH="/opt/jmeter/bin:${PATH}"
WORKDIR /tests
ENTRYPOINT ["jmeter"]
Build it with docker build -t jmeter:5.6.3 .. The base image gave us Ubuntu 26.04.1 and OpenJDK 21.0.13.1, with curl already installed. JMeter 5.6.3 needs Java 8 or later, so any current LTS runtime works.
A few choices in that file matter more than they look:
- The checksum line.
sha512sum -cfails the build if the download is corrupt or not what you asked for. The hash comes from the.sha512file next to the archive on archive.apache.org. - archive.apache.org for the download. The archive keeps older releases, so the URL for 5.6.3 still works after the next release ships. It is slow: our build took 7 minutes 22 seconds. Build once and push the image to your registry.
ENTRYPOINT ["jmeter"]withWORKDIR /tests. Everything after the image name indocker runbecomes JMeter arguments, and relative paths resolve inside the mounted test folder.
The image measured 491 MB in docker image ls, against 341 MB for the bare eclipse-temurin:21-jre. We did not build a plugin image for this article. Plugins are jar files: JMeter loads them from lib/ext, with their dependencies in lib, and our Ultimate Thread Group guide lists the two jars that plugin needs. In an image, those folders are /opt/jmeter/lib/ext and /opt/jmeter/lib.
How do you run a JMeter test in a Docker container?
Mount the folder with your test plan at /tests and pass JMeter’s non-GUI arguments after the image name. The target has to be reachable from inside the container: we ran nginx on the same Docker network (--network), with the plan reading the host name from a property. The container writes the results file, the log and the HTML report back into the same folder, and removes itself when the test ends:
docker run --rm --network jmlab -v "$PWD/tests":/tests jmeter:5.6.3 \
-n -t plan.jmx -Jhost=web -l results.jtl -e -o report
Here jmlab is the Docker network the nginx container web runs on, and the plan reads its target with ${__P(host,web)}; inside a container, localhost is the container itself. Our plan ran 10 threads for 20 loops against that nginx container: 200 requests, 0 errors, and 3.2 seconds from docker run to exit. results.jtl, jmeter.log and the report folder appeared in tests/ on the host. These are the same flags as a non-GUI run on your machine; the report itself is covered in our guide to the JMeter HTML report.
Three things to know:
- A second run fails on the report folder. With
report/already there, JMeter stopped before the test withCannot write to '/tests/report' as folder is not emptyand exit code 1. Add-fto delete the old results file and report folder first. - The exit code does not tell you whether the test passed. A run where 1 of 1 requests failed (100% errors) exited with 0. So did a run where the JVM ran out of heap and recorded no samples at all. In CI, fail the job on the error rate in
results.jtlorreport/statistics.json, not on$?. - File ownership. The image sets no
USER, so JMeter runs as root inside the container. To have it write the results as a given user, pass--user "$(id -u):$(id -g)": our run with--user 1000:1000completed normally. (On our Mac, Docker Desktop mapped the files to the host user either way; we did not test a Linux host.)
How much memory does JMeter need in a container?
JMeter’s start script sets the heap with a fixed default, HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m", and that default ignores the container’s memory limit. Our jmeter.log printed Max memory = 1073741824 with no limit and with --memory=512m alike. Override HEAP with an environment variable and set it to about 50% of the container’s memory: in our runs, 75% still got the container killed.
To see what happens at the edge, we ran a plan whose single sampler allocated 700 MiB inside a 512 MB container, with swap off (--memory=512m --memory-swap=512m):
HEAP setting | Heap JMeter got | What happened | Exit code |
|---|---|---|---|
Default (-Xms1g -Xmx1g) | 1,024 MiB | Killed by the kernel, empty results file, no error in jmeter.log | 137 |
-XX:MaxRAMPercentage=75.0 | 384 MiB | Killed by the kernel, empty results file | 137 |
-XX:MaxRAMPercentage=50.0 | 256 MiB | java.lang.OutOfMemoryError: Java heap space in jmeter.log, 268 MB heap dump written to /tests | 0 |
A heap at 75% of the container still got the container killed: the JVM needs memory outside the heap for threads, classes and the garbage collector, and the remaining 128 MiB was not enough for that. At 50%, the JVM failed on its own terms, with an error in the log you can find. In the same 512 MB container without swap, the 50% setting ran a normal HTTP plan of 50 threads and 10,000 requests with 0 errors.
docker run --rm --memory=2g --memory-swap=2g \
-e HEAP="-XX:MaxRAMPercentage=50.0 -XX:MaxMetaspaceSize=256m" \
-v "$PWD/tests":/tests jmeter:5.6.3 -n -t plan.jmx -l results.jtl
Three details from these runs:
--memoryalone did not limit much. Without--memory-swap, Docker allows swap equal to the memory limit on top of it. With swap allowed, the sampler’s 700 MiB fit under the default 1 GB heap inside a “512 MB” container, and the run finished, swapping instead of failing.- Heap dumps land in your mounted folder. The start script adds
-XX:+HeapDumpOnOutOfMemoryError, and the working directory is/tests, so the 50% run left a 268 MBjava_pid24.hprofnext to the test plan. JMeter had the same process ID in every container, so a later out-of-memory run could not write its dump (File exists) until we deleted the old one. - Do not uncomment
RUN_IN_DOCKER. The start script has a commented line for Docker with-XX:+UseCGroupMemoryLimitForHeap. Java 21 no longer has that option: setting it made the container exit withUnrecognized VM option 'UseCGroupMemoryLimitForHeap'. Current Java versions read the container limit by default, which is why the percentage flags work.
For the heap size itself, a bigger plan needs more: listeners that keep results in memory, large responses and many threads all add up. Our guide on increasing JMeter’s heap size covers the setting outside Docker.
How do you run distributed JMeter tests with Docker Compose?
Run one container per JMeter server with jmeter-server as the entrypoint, and a controller container that starts the test with -R. All containers need the same image, RMI over SSL either set up or turned off on both sides, and a fixed port and host name for each server. This Compose file ran our test:
services:
web:
image: nginx:1.29-alpine
server1:
image: jmeter:5.6.3
entrypoint: ["jmeter-server"]
command: ["-Jserver.rmi.ssl.disable=true", "-Jserver.rmi.localport=50000",
"-Djava.rmi.server.hostname=server1"]
server2:
image: jmeter:5.6.3
entrypoint: ["jmeter-server"]
command: ["-Jserver.rmi.ssl.disable=true", "-Jserver.rmi.localport=50000",
"-Djava.rmi.server.hostname=server2"]
controller:
image: jmeter:5.6.3
volumes: ["./tests:/tests"]
depends_on: [web, server1, server2]
profiles: ["run"]
Start the servers with docker compose up -d web server1 server2, then run the test from the controller:
docker compose run --rm controller \
-n -t plan.jmx -R server1,server2 -Jserver.rmi.ssl.disable=true -l results.jtl
The run profile keeps the controller out of docker compose up, so it starts only when you ask for a test. Here is what the runs showed (the plan reads its thread count with ${__P(threads,10)}):
| Run | Requests | Result |
|---|---|---|
| 10 threads x 20 loops, 2 servers | 400 | Each server ran the full plan: 200 from server1-Users, 200 from server2-Users |
Same, with -Jthreads=5 on the controller | 400 | The servers ignored it and kept the default of 10 threads |
Same, with -Gthreads=5 | 200 | -G sends the property to every server |
Servers started without server.rmi.ssl.disable | 0 | Server failed to start ... rmi_keystore.jks (No such file or directory) |
Controller without server.rmi.ssl.disable | 0 | Exit 1, Following remote engines could not be configured:[server1, server2] |
The first row is the one that surprises people: JMeter’s remote testing guide states that each server runs the whole plan, so 1,000 threads on 6 servers is 6,000 threads. Divide the thread count by the number of servers yourself, or pass it with -G. The JMeter thread groups guide explains where the thread count lives in the plan.
Two more rules from the same guide apply in containers. Data files such as CSVs are not sent to the servers, so each server container needs them at the same path: in the Compose file above, give server1 and server2 the ./tests:/tests volume too. And every node needs either a keystore for RMI over SSL or SSL turned off. We would turn it off only on a private network such as a Compose network; across hosts, the guide’s steps create rmi_keystore.jks with create-rmi-keystore.sh and copy it to every node. Across hosts you also need open ports both ways, because the servers connect back to the controller to return results; client.rmi.localport fixes the controller’s ports for a firewall rule. Our older notes on running a distributed JMeter test cover the setup without Docker.
Running JMeter tests without maintaining Docker images
Docker gives you a repeatable JMeter, but you still own the image, the heap sizing, the RMI setup and the machines the containers run on. To generate load from many places, you also need machines in each region, each running the same image.
LoadFocus runs JMeter tests on its own cloud load generators instead: you upload the .jmx file with its CSV files, set the virtual users, duration and ramp-up in the browser, and pick from 25 cloud regions, with results broken down by region. Nothing is installed on your side, so there is no image, heap or RMI setup to maintain. Before uploading, the free JMeter script validator checks the .jmx for errors.
Frequently Asked Questions
Is there an official Apache JMeter Docker image?
No. Apache publishes JMeter as zip and tgz archives, and Docker Hub has no official JMeter image (apache/jmeter returns 404). Community images such as alpine/jmeter and justb4/jmeter exist, but check which JMeter version their tags hold: justb4/jmeter stops at 5.5. A Dockerfile of about 15 lines builds your own image from the Apache archive.
How do I run a JMeter test in Docker?
Build an image with Java and JMeter, then run docker run --rm -v "$PWD/tests":/tests <image> -n -t plan.jmx -l results.jtl -e -o report. The -v flag mounts your test folder, -n runs JMeter without its GUI, and the results file and HTML report are written back to the mounted folder.
How much memory should a JMeter container have?
Give the container the memory your plan needs, then set the heap to about half of it with HEAP="-XX:MaxRAMPercentage=50.0". JMeter’s default heap is a fixed 1 GB whatever the container limit is. In our 512 MB container a 75% heap still got the container killed when the plan ran out of memory, while at 50% JMeter logged an OutOfMemoryError instead. A 512 MB container with a 50% heap ran 50 threads and 10,000 requests without errors.
Why does my JMeter container exit with code 137?
Exit code 137 means the kernel killed the process, usually because the container used more memory than its limit. JMeter’s default 1 GB heap does this in a smaller container: ours died with an empty results file and no error in jmeter.log. Set the HEAP environment variable to about half the container’s limit (-XX:MaxRAMPercentage=50.0); 75% still got ours killed.
Should I run the JMeter GUI in a Docker container?
No. We did not try it, and there is little reason to. The JMeter manual says to build and debug tests in GUI mode and run load tests in CLI mode. Edit the plan in JMeter on your own machine, save the .jmx file, and run it in the container with -n.
Sources
- JMeter 5.6.3 binary archive and its SHA-512: archive.apache.org/dist/jmeter/binaries/, downloaded and verified 3 December 2026.
- Remote (distributed) testing: Apache JMeter User’s Manual, chapter 13, jmeter.apache.org/usermanual/remote-test.html, read 3 December 2026 (each server runs the full plan, data files are not sent,
-G, RMI ports and SSL keystore). - Properties
server.rmi.ssl.disable,server.rmi.localportandclient.rmi.localport: Apache JMeter User’s Manual, Properties Reference, jmeter.apache.org/usermanual/properties_reference.html, read 3 December 2026. - GUI mode for building tests, CLI mode for load tests: Apache JMeter User’s Manual, Getting Started, jmeter.apache.org/usermanual/get-started.html, read 3 December 2026.
- Default
HEAP, the heap dump flag and the commentedRUN_IN_DOCKERline: thebin/jmeterstart script in the JMeter 5.6.3 archive. - Docker Hub pages for alpine/jmeter and justb4/jmeter (pull counts, tags, update dates) and the 404 for apache/jmeter: hub.docker.com, read 3 December 2026.
- LoadFocus JMeter runs and the script validator: loadfocus.com/jmeter-load-testing and loadfocus.com/jmeter-script-validator, read 3 December 2026.
- Test runs: Docker Desktop 29.4.3 (engine VM with 10 CPUs and 26 GB) and Docker Compose 5.1.3 on an Apple M1 Max, image built from the Dockerfile above, target nginx 1.29 (Alpine), 3 December 2026. Memory results come from
docker inspect(OOMKilled, exit code) and theMax memoryline of each run’s jmeter.log.