Docker image is used to create container which could be run using Docker, Kubernetes.
I have used Alpine image as base image on which JMeter is downloaded and Plugin manager is installed, sample file Github
In docker folder you would two files that are required to create JMeter docker container.
- Dockerfile: This is used to create docker image
- launch.sh: This file is executed on start of container
Below are the variables that determines the JMeter version and timezone for the container
ENV TIMEZONE Asia/Kolkata
launch.shIn this file you can configure the properties and plugins that are required to be installed.
Below show the sample on adding properties, all the properties will be added to user.properties which will override jmeter.properties file.
echo server.rmi.ssl.disable=true >> /opt/apache-jmeter-5.3/bin/user.properties
I have configure Dummy Sampler and Custom Thread Groups to be installed on Container start, you can add more as pre requirement.
We determine if JMeter should be running in Master mode (supervisor for other slave nodes) or Slave node.
Below code will decide on how JMeter needs to be started, and "mode" variable can be configured using environment variables for container.
if [ "$mode" == "master" ]; then
jmeter-server >> /mnt/jmeter/logs/$mode-jmeter-server_`date '+%Y-%m-%d_%H-%M-%S'`.log
Build and push image to repository
docker build -t jmeter .
docker push <repository-name>
Once image is pushed to repository we can use it.