Run a GUI app on a Docker container
Run a graphical application inside a Docker container by sharing the host X11 socket and DISPLAY.
1 min read
Updated
To display a GUI application from inside a container you must share the host's X11 socket and DISPLAY environment variable, and mount the working directory. This snippet shows the docker run invocation and notes the headless flag needed by Java applications. The command is below.
If the application is a Java binary, make sure you add the JVM option: -Djava.awt.headless=true
bash
docker run -it --rm -v $(pwd):/app -w /app -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 <image> </path/to/bin>