Want to have a virtual display running inside docker? You will need xvfb which is an ‘X virtual frame-buffer’ display server.
The following Dockerfile code installs xfce4 in a virtual screen.
[code]ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get install keyboard-configuration -y
RUN apt install xfce4 xfce4-goodies -y
RUN apt install xvfb -y
ENV DISPLAY :99
WORKDIR /root
ADD . .
RUN chmod a+x display.sh
CMD { bash display.sh; }
[/code]
Because you still need a tty when running the docker file, run the Xfvb in a shell file at runtime. Here we are using DISPLAY number 99 for arbitrary reason.
docker run -t image
[code]export DISPLAY=:99
Xvfb :99 -screen 0 1000x1000x16 &
xrandr –query
sleep 5
nohup startxfce4 &
[/code]
Use xdotool to click the panel button (Add to script after startxfce4 has ran)
[code]apt install xdotool -y
xdotool mousemove 493 539 click 1[/code]
Use xdotool to press enter
[code]xdotool key KP_Enter[/code]
Verify the screen is “on” using
[code]xrandr –query[/code]
Or take a screenshot using scrot
Comments 1