2

i made a Docker-Image of JMeter because I want to run it remote (and from a cloud). If I run the Image I am getting the error: 'No X11 DISPLAY variable was set, but this program performed an operation which requires it.'

I've updated the ssh_config file and the sshd_config file (as mentioned in similiar questions) but it still don't work.

enter image description here

And my DISPLAY variable is set to localhost:10.0. It's maybe useful to know that i am doing this on a VM on Ubuntu 19.04.

Thanks for your help.

jww
  • 97,681
  • 90
  • 411
  • 885
noob123
  • 63
  • 1
  • 2
  • 9

3 Answers3

3

After a few hours searching I found the solution: (credit) My setup is ubuntu 18.04, lxde, this docker build I modified the run script like this:

#!/bin/bash
#
# Run JMeter Docker image with options

NAME="jmeter"
JMETER_VERSION=${JMETER_VERSION:-"5.4"}
IMAGE="justb4/jmeter:${JMETER_VERSION}"

# Finally run
xhost +
docker run -e DISPLAY=$DISPLAY  --rm --name ${NAME} -i -v ${PWD}:${PWD} -v /tmp/.X11-unix:/tmp/.X11-unix:ro  -w ${PWD} ${IMAGE} $@
xhost -

this work, by term of effort it's much less than another method (vnc...)

FabuLoops
  • 51
  • 1
  • 4
Tiana987642
  • 696
  • 2
  • 10
  • 28
1

You should declare this DISPLAY variable using ENV command like:

ENV DISPLAY :10

But be aware that you need to have a display server, at least Xvfb.

So running JMeter GUI in Docker container is possible, but you will have to treat it like a normal Linux desktop, it can be a minimal one like Xfce

Example Dockerfile which downloads latest JMeter, installs virtual desktop and makes it available via VNC and RDP

FROM alpine:edge

ENV DISPLAY :99
ENV RESOLUTION 1366x768x24

RUN  echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
    && apk add --no-cache curl xfce4-terminal xvfb x11vnc xfce4 openjdk8-jre bash xrdp \
    && curl -L https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.1.1.tgz >  /tmp/jmeter.tgz \
    && tar -xvf /tmp/jmeter.tgz -C /opt \
    && rm /tmp/jmeter.tgz \
    && curl -L https://jmeter-plugins.org/get/ > /opt/apache-jmeter-5.1.1/lib/ext/jmeter-plugins-manager.jar \
    && echo "[Globals]" > /etc/xrdp/xrdp.ini \
    && echo "bitmap_cache=true" >> /etc/xrdp/xrdp.ini \
    && echo "bitmap_compression=true" >> /etc/xrdp/xrdp.ini \
    && echo "autorun=jmeter" >> /etc/xrdp/xrdp.ini \
    && echo "[jmeter]" >> /etc/xrdp/xrdp.ini \
    && echo "name=jmeter" >> /etc/xrdp/xrdp.ini \
    && echo "lib=libvnc.so" >> /etc/xrdp/xrdp.ini \
    && echo "ip=localhost" >> /etc/xrdp/xrdp.ini \
    && echo "port=5900" >> /etc/xrdp/xrdp.ini \
    && echo "username=jmeter" >> /etc/xrdp/xrdp.ini \
    && echo "password=" >> /etc/xrdp/xrdp.ini

EXPOSE 5900
EXPOSE 3389

CMD ["bash", "-c", "rm -f /tmp/.X99-lock && rm -f /var/run/xrdp.pid\
 && nohup bash -c \"/usr/bin/Xvfb :99 -screen 0 ${RESOLUTION} -ac +extension GLX +render -noreset && export DISPLAY=99 > /dev/null 2>&1 &\"\
  && nohup bash -c \"startxfce4 > /dev/null 2>&1 &\"\
   && nohup bash -c \"x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :99 -forever -bg -nopw -rfbport 5900 > /dev/null 2>&1\"\
    && nohup bash -c \"xrdp > /dev/null 2>&1\"\
     && nohup bash -c \"/opt/apache-jmeter-5.1.1/bin/./jmeter -Jjmeter.laf=CrossPlatform > /dev/null 2>&1 &\"\
       && tail -f /dev/null"]

You can build it like:

docker build -t jmeter.

and once done kick off the container using Docker run command like:

docker run -p 5900:5900 -p 3389:3389 jmeter

You might also find Make Use of Docker with JMeter - Learn How guide useful.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
-3

there is NO solution for Docker-Images. Because Docker does not support GUI and therefore i am getting this error. So if you are working with Docker and you are getting this error, just ignore it or update your image to only non-gui.

Cheers

noob123
  • 63
  • 1
  • 2
  • 9