Running GUI applications using Docker in Mac, Linux and Windows
2 min readOct 7, 2018
Docker, primarily used for running background applications, can also run GUI applications. While this usage is not very common, it can be beneficial for offloading resource-intensive tasks to Docker containers for specific GUI applications.
To run GUI applications, you need to have XServer installed on your local machine
Running On MacOS
Prerequisites:
- Install XQuartz from https://www.xquartz.org Installation of XQuartz will require to restart your machine.
- Ensure the
xhost
command is available after 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
I use Twitter to share on software design, architecture, AI, life and my journey, you can follow me there.