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>Something wrong or want to discuss this article?
Get in touch
Related articles
- Sep 25, 2026 Ṣeto: a small orchestrator for DockerDocker · Networking · Security · Hardware · Traefik · Linux · Python
- Sep 27, 2025 Fixing Docker Swarm Startup Failures on Debian 13 Due to Network TimingDocker · Linux · Networking
- Sep 27, 2025 Installing NVIDIA Drivers and CUDA 12.6 on Debian 13 (RTX 5070)Linux · GPU · CUDA · Docker