Running Java GUI application in Docker

This is a more specific use case of running GUI application with Docker, the procedure is pretty simple (and most option are common for most GUI application), You mount the UNIX socket for the display server, and define the DISPLAY variable, mount any necessary volumes you need the application to have access to, and if you need any unique network access define this as well.

In my use case, I need to run a GUI application to manage a remote DB in a isolated environment which can only be reached via VPN or ssh tunneling, and so I need the container to have access to a tunnel I create, and this is why I’m using the host network option.

In the above example I’m using DbVisualizer as I wanted to test the application without contaminating my system with all the Java runtime requirements.

I also mount my local fonts folder to the container, as I like to use some mono fonts I have in my system, and also exporting few JAVA_OPTIONS to enable anti-aliasing and having a better interaction with my desktop environment.