Run GUI Applications Inside Docker Containers with x11docker – A Step‑by‑Step Guide
This tutorial explains how to install Docker and x11docker on an Ubuntu desktop, outlines x11docker's security‑enhanced features, and provides a complete walkthrough for pulling and running a GUI app such as VLC inside a container with GPU, audio, and clipboard support.
Required Tools
An Ubuntu desktop Linux distribution with a user that has sudo privileges.
Install Docker
1. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg2. Add the Docker APT repository (replace $(lsb_release -cs) with your Ubuntu codename):
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/null3. Install required packages for HTTPS transport:
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y4. Update the package index and install Docker Engine:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y5. (Optional) Allow the current user to run Docker without sudo: sudo usermod -aG docker $USER Log out and log back in for the group change to take effect.
6. (Alternative) Quick installation via Docker’s convenience script:
sudo apt-get install curl wget uidmap -y
wget -qO- https://get.docker.com/ | sudo sh7. (Optional) Enable rootless Docker operation:
dockerd-rootless-setuptool.sh installInstall x11docker
Install X11 utilities required by x11docker:
sudo apt-get install xpra xserver-xephyr xinit xauth xclip x11-xserver-utils x11-utils -yDownload and install the latest x11docker script:
curl -fsSL https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker | sudo bash -s -- --updateUpdate x11docker later with:
sudo x11docker --updatex11docker Features
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 D‑Bus inside the container
Support for multiple container runtimes and back‑ends, including Podman
Run a GUI Application with x11docker
Pull a container image that contains a GUI program (example uses VLC): docker pull jess/vlc Start the container with audio support and a shared video directory:
x11docker --pulseaudio --share=$HOME/Videos jess/vlcThe VLC window opens inside the container. Performance is comparable to a native installation, with a modest overhead.
Reference
https://github.com/mviereck/x11docker
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
