Notes on Running GUI Applications in Docker

John O'Connor
3 min readMar 24, 2020

--

Image by Radek Grzybowski

I love Inkscape. It’s one of my favorite vector graphics programs. And when XQuartz (the X-11 window manager for Mac) stopped being supported, I couldn’t run it on my Mac anymore. That made me sad.

I love Inkscape. It’s one of my favorite vector graphics programs. And when XQuartz (the X-11 window manager for Mac) stopped being supported, I couldn’t run it on my Mac anymore. That made me sad.

I’m also a huge fan of containerization in general. I’ve saved a huge amount of time and energy not having to uninstall and reinstall libraries by deploying my applications as Docker containers.

However, while Docker has worked great for “headless” applications, when it comes to GUI applications it’s fallen flat.

While the technology needed to “pipe” the X-Windows display from the container exists and works well in Linux, attempting to pipe it to my Mac without XQuartz has been a non-starter.

What options are there?

XVFB

XVFB allows you to render an X Frame buffer in software. This allows you to render an X display into RAM, files, and in other contexts where you don’t have access to a screen / view.

Findings

This is a popular tool for rendering and validating application UI using automated testing tools, and it works great for this purpose. However, it does not address keyboard and mouse communication and thus was not a viable solution without additional work.

X11VNC

VNC is the Virtual Network Computing specification. VNC describes how to interact with a remote computer, and includes input (keyboard and mouse) as well as display. With VNC, the x11 server renders the display and the input / output are sent via network remotely to another machine.

The x11vnc/desktop base docker image is an Ubuntu base image that exposes VNC via a dynamic web application. It generates a web link from the Docker container that can then be followed, allowing access to GUI applications running in docker using a web interface.

As an example, you can run inkscape by running the following docker command:

docker run -t -p 6080:6080 x11vnc/inkscape-desktop

This will generate a web URL and a direct VNC connection url / password:

Open your web browser with URL:http://localhost:6080/vnc.html?resize=downscale&autoconnect=1&password=<password>or connect your VNC viewer to localhost:5900 with password <password>

You can also mount volumes on your host machine to a container volume, allowing you to edit files locally through the container:

docker run -t -p 6080:6080 -v /mnt/path_to_container:/home/path_to_host x11vnc/inkscape-desktop

Findings:

This was the superior solution for what I wanted to do, and performance was generally very fast and smooth — faster than even running Inkscape in XQuartz.

--

--

John O'Connor
John O'Connor

Written by John O'Connor

Entrepreneur. Engineer. Educator.

No responses yet