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.

First building the running container

build it with

and now we can set a small bash script to run the application for us,

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.

Resources

  • http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
  • https://unix.stackexchange.com/questions/386767/selinux-and-docker-allow-access-to-x-unix-socket-in-tmp-x11-unix
  • https://adam.younglogic.com/2017/01/gui-applications-container/
  • https://wiki.archlinux.org/index.php/Java_Runtime_Environment_fonts
  • https://docs.docker.com/network/host/

Related Post

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *