Cloud Native 7 min read

Run GUI Applications in Docker Containers with x11docker: A Step‑by‑Step Guide

This tutorial explains how to run graphical applications inside Docker containers using x11docker, covering required tools, Docker installation, x11docker setup, and a practical VLC media player example, while highlighting features such as GPU acceleration, audio, clipboard sharing, and security considerations.

Open Source Linux
Open Source Linux
Open Source Linux
Run GUI Applications in Docker Containers with x11docker: A Step‑by‑Step Guide

Required Tools

You need a running Ubuntu Linux desktop with a user that has sudo privileges.

Install Docker

First add Docker’s official GPG key and repository, then install Docker Engine and related packages.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Optionally add your user to the docker group to run Docker without sudo and log out/in.

sudo usermod -aG docker $USER

Install x11docker

Install required X11 utilities, then download and install x11docker.

sudo apt-get install xpra xserver-xephyr xinit xauth xclip x11-xserver-utils x11-utils -y
curl -fsSL https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker | sudo bash -s -- --update
sudo x11docker --update

Using x11docker

Pull a GUI‑enabled image (e.g., VLC) and run it with x11docker, sharing audio and your video directory.

docker pull jess/vlc
x11docker --pulseaudio --share=$HOME/Videos jess/vlc

The VLC window opens inside the container, demonstrating that GUI applications can run securely in Docker.

Key Features of x11docker

GPU hardware acceleration

PulseAudio or ALSA sound support

Clipboard sharing

Printer and webcam access

Persistent home directory

Wayland support

Locale creation

Multiple init systems and DBus inside the container

Support for various container runtimes and back‑ends, including Podman

x11docker creates a non‑privileged container user, reducing security risks associated with X11.

Conclusion

By installing Docker and x11docker, you can run any GUI application—such as VLC—inside a container, enabling isolated development and deployment of graphical software.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GUItutorialcontainersx11docker
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.