Running GUI applications using Docker

Docker, being mostly used for applications running in backgroud, can also be used for running GUI applications. Although it is not very common, but still it can be useful for delegating heaving-lifting to docker containers for some applications with GUI.

For GUI applicaitons to run, XServer is needed to be installed on local machine.

Running On MacOS

Prerequisites:

  • Install XQuartz from https://www.xquartz.org Installation of XQuartz will require restart your machine.
  • Make sure xhost command is available after the installation
  • Configure XQuartz to allow connections from network clients from Preferences -> Security tab

To run:

  • On your local machine, start XQuartz
  • Run xhost + ${hostname} after
  • Set DISPLAY var in the container: export DISPLAY=<IP>:0
  • Run xclock in the container to test the X11
  • Now you can run your app with GUI

Running On Linux

Prerequisites:

To run:

  • On your local machine, start XQuartz
  • Run xhost + ${hostname} in the local machine
  • Set DISPLAY var in the container: export DISPLAY=<IP>:0.0
  • Run xclock in the container to test the X11
  • Now you can run your app with GUI

Running On Windows

Prerequisites:

  • Install VcXsrv Windows X Server (https://sourceforge.net/projects/vcxsrv/) manually or choco install vcxsrv
  • Run Xlaunch from the start menu and perform the initial configuration.
  • Make sure to save to configuration file before you click finish. Save it to one of the following locations:
%appdata%\Xming
%userprofile%\Desktop
%userprofile%

To run:

  • Run Xlaunch
  • Find up by ipconfig on the local machine
  • Set DISPLAY var in the container: export DISPLAY=<IP>:0.0
  • Run xclock in the container to test the X11
  • Now you can run your app with GUI