Operations 7 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Run GUI Applications Inside Docker Containers with x11docker – A Step‑by‑Step Guide

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.gpg

2. 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/null

3. Install required packages for HTTPS transport:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

4. Update the package index and install Docker Engine:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

5. (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 sh

7. (Optional) Enable rootless Docker operation:

dockerd-rootless-setuptool.sh install

Install x11docker

Install X11 utilities required by x11docker:

sudo apt-get install xpra xserver-xephyr xinit xauth xclip x11-xserver-utils x11-utils -y

Download and install the latest x11docker script:

curl -fsSL https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker | sudo bash -s -- --update

Update x11docker later with:

sudo x11docker --update

x11docker 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/vlc

The VLC window opens inside the container. Performance is comparable to a native installation, with a modest overhead.

Reference

https://github.com/mviereck/x11docker

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.

DockerGUIcontainersx11dockerVLC
Liangxu Linux
Written by

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.)

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.