Can't run a Docker container that needs an X server in CI

I am working on a Docker container for PGModeler (, which is a QT application. Benefits are that, unlike many of the others I’ve seen, it does not require a root user or --privileged. However, it does require access to the host’s display. During CI, I run goss tests against the container and need the container to access the host’s DISPLAY. I am assuming the Action runners don’t have a display available.

I run the container with the following commands:

xhost +local:
docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp/saves:/app/savedwork artis3n/pgmodeler:${TAG:-test}
xhost -local:

The test runs the following commands:

xhost +local:
mkdir -p /tmp/saves; touch /tmp/saves/exist.txt
dgoss run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp/saves:/app/savedwork artis3n/pgmodeler:${TAG:-test}
CI=true dive artis3n/pgmodeler:${TAG:-test}
xhost -local:

The error I get is:

xhost +local:
xhost:  unable to open display ""
make: *** [test] Error 1

Example workflow logs with the error:

Is there a possible workaround for this with a managed runner? Do I need to host my own runner or use another CI product to get a display available for my container to be tested appropriately?

You could start your own screen-less X server either in the container or on the runner, using Xdummy or a VNC server. If you want to containerize the application VNC might be a good idea anyway, so people can run the container on a server and see the display somewhere else.


That is a very interesting and useful point, I will think about that further.

1 Like

I’ve used xvfb for running software on a cluster in the past by using the xvfb-run wrapper (automatically starts and shuts down an xvfb instance) to run the commands that need an X server.

Xdummy (as suggested by airtower-luna) has more features/extensions than xvfb though, which could make it a better choice if xvfb is missing support for a feature that is needed.

1 Like

I didn’t want to modify my image specifically for the github action CI use case, since CI works locally. I want to be able to test the image as-is on a platform.

I ended up moving my repo to CircleCI’s machine image, which lets me run xhost commands and run my CI with access to an Xserver.

You do not have to modify your image. You can start the VNC os xvfb or xdummy on the host and forward the DISPLAY to the container. This is quite easy to do, I’v done that quite extensively to run robotic simulations with gazebo and that even allowed to run some GPU - based rendering in-memory for the XServer.