Skip to main content
Back to blog
tutorials 9 March 2020 2 min read

Docker and JMeter

How to leverage Docker containerization for Apache JMeter testing, including standalone, server, and distributed testing modes.

M

Mark

Performance Testing Expert

With more and more test environments moving to the cloud it makes sense to embrace the cloud and consider how we can take advantage of it. Containerization technology can be leveraged for Apache JMeter testing in cloud environments.

Docker Image Setup

Rather than building a custom image, use the pre-built Docker image egaillardon/jmeter from Docker Hub:

docker pull egaillardon/jmeter

Execution Modes

JMeter can operate in three modes within containers:

  1. Standalone - Interactive or detached
  2. Server mode - Running as a JMeter server
  3. Distributed testing mode - Controller with remote servers

Code Examples

Interactive Standalone

Run JMeter interactively with output visible in the terminal:

docker run --interactive --tty --rm --volume `pwd`:/jmeter egaillardon/jmeter --nongui --testfile test.jmx --logfile result.jtl

Detached Standalone

Run JMeter in the background:

docker run --detach --rm --volume `pwd`:/jmeter egaillardon/jmeter --nongui --testfile test.jmx --logfile result.jtl

Server Mode

Run JMeter as a server for distributed testing:

docker run --detach --publish 1099:1099 --rm egaillardon/jmeter -Jserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.1.1 -Jserver.rmi.localport=1099 --server

Distributed Client

Run the JMeter controller connecting to remote servers:

docker run --detach --rm --volume `pwd`:/jmeter egaillardon/jmeter -Jserver.rmi.ssl.disable=true --nongui --testfile test.jmx --remotestart 192.168.1.1 --logfile result.jtl

Key Parameters

ParameterDescription
--interactiveKeep STDIN open
--ttyAllocate a pseudo-TTY
--rmRemove container after exit
--volumeMount local directory
--detachRun in background
--publishExpose port
-Jserver.rmi.ssl.disable=trueDisable RMI SSL
-Djava.rmi.server.hostnameSet RMI hostname

Conclusion

Containerization enables rapid deployment and dynamic scaling of JMeter slaves for performance testing scenarios requiring higher thread counts. This approach simplifies infrastructure management and allows for consistent, reproducible test environments.

Further Reading

Tags:

#docker #jmeter #performance-testing #containers #distributed-testing

Need help with performance testing?

Let's discuss how I can help improve your application's performance.

Get in Touch