VOOZH about

URL: https://thenewstack.io/run-gui-applications-as-containers-with-x11docker/

⇱ Run GUI Applications in Docker Containers With x11docker - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2023-09-09 06:00:26
Run GUI Applications in Docker Containers With x11docker
Containers / Linux

Run GUI Applications in Docker Containers With x11docker

You can run GUI applications from within Docker containers, thanks to x11docker. Deploy custom containers from your own images and see how it works.
Sep 9th, 2023 6:00am by Jack Wallen
👁 Featued image for: Run GUI Applications in Docker Containers With x11docker
This article has been updated since it was originally published on Sept. 9, 2023.

As a developer, you might have a need to work with GUI containers. If that’s the case, you’ll quickly find that the traditional Docker runtime engine doesn’t provide for running GUI applications (unless they are of the web-based type). When you want to develop a containerized GUI application, what do you do?

Fortunately, there are plenty of third-party applications that make it fairly easy to launch GUI containers on a desktop. As you might expect, this does require a desktop environment (otherwise, you’d be developing on a more traditional server-based setup). One such application is called x11docker. As the name implies, this application works with the Linux X display server (which means you’ll need a Linux distribution to make it work).

Overview: What Is x11docker?

x11docker is a tool that allows developers to run GUI (Graphical User Interface) applications within Docker containers, providing features such as GPU hardware acceleration, sound support with PulseAudio or ALSA, clipboard sharing, and printer/webcam access.

Key Features of x11docker:

  • Supports multiple container runtimes and backends.
  • Includes Wayland support and language locale creation.
  • Allows for persistent home folder and supports several init systems and DBus within containers.

Security Considerations:

x11docker avoids X server leaks by using multiple X servers, making it a secure option. This tool also creates a container user similar to the host user to avoid having to use root within the container.

Installation Process:

The article provides instructions on installing x11docker on a running instance of Ubuntu-based desktop operating system, including:

  1. Installing the Docker runtime engine.
  2. Adding necessary repositories and dependencies.
  3. Installing x11docker.

After installation, the article shows how to use x11docker by pulling the VLC media player image and running it within a container using the command x11docker –pulseaudio –share=$HOME/Videos jess/vlc.

Overall, x11docker allows developers to create custom containers for GUI applications, providing a convenient way to develop and deploy desktop software.

Getting Started With Docker and x11docker:

As a developer, you might have a need to work with GUI containers. If that’s the case, you’ll quickly find that the traditional Docker runtime engine doesn’t provide for running GUI applications (unless they are of the web-based type). When you want to develop a containerized GUI application, what do you do?

Fortunately, there are plenty of third-party applications that make it fairly easy to launch GUI containers on a desktop. As you might expect, this does require a desktop environment (otherwise, you’d be developing on a more traditional server-based setup). One such application is called x11docker. As the name implies, this application works with the Linux X display server (which means you’ll need a Linux distribution to make it work).

The x11docker application includes features like:

  • GPU hardware acceleration
  • Sound with PulseAudio or ALSA
  • Clipboard sharing
  • Printer and webcam access
  • Persistent home folder
  • Wayland support
  • Language locale creation
  • Several init systems and DBus within containers
  • Supports several container runtimes and backends (including podman).

You might be asking yourself, “Isn’t X11 insecure?” Yes, it is. Fortunately, x11docker avoids X server leaks by using multiple X servers. So you can use the tool without worrying you’ll be exposing yourself, your system, or your containers to the typical X11 server weaknesses.

One thing to keep in mind is that x11docker creates an unprivileged container user. That user’s password is x11docker and restricts the capabilities of the container. Because of this, some applications might not behave as expected. For example, when trying to run the Tor Browser from within a container, it cannot access /dev/stdout, which means the container will not run. That’s not the case with all containers. I’ll demonstrate with the VLC media player, which does work as expected.

I want to show you how to install x11docker on a running instance of a Ubuntu-based desktop operating system. Of course, the first thing you must do is install the Docker runtime engine. For that, I’ll show you two different methods.

Ready? Let’s get this done.

What You’ll Need

As I’ve already mentioned, you’ll need a running instance of a Ubuntu-based Linux desktop distribution. You’ll also need a user with sudo privileges. That’s it.

Installing Docker Containers

First, we’ll go with the traditional method of installing the Docker runtime engine. The first thing to do is add the official Docker GPG to the system with the command:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Next, we must add the Docker repository, so we can install the software. This is done with the command:

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

With the repository added, we’ll then install a few dependencies using the command:

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

Update apt with:

sudo apt-get update

We can now install Docker with the command:

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

To be able to run Docker command without sudo (which can be a security risk), add your user to the docker group with the command:

sudo usermod -aG docker $USER

Log out and log back in so the changes take effect.

If you’d rather do this the quick way, you can install Docker with the following commands:

sudo apt-get install curl wget uidmap -y
wget -qO- https://get.docker.com/ | sudo sh

To be able to run Docker rootless, issue the following command:

dockerd-rootless-setuptool.sh install

How To Install x11docker

Before we can install x11docker, we must install a few dependencies. This can be done with the command:

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

Next, install x11docker with the command:

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

You can then update x11docker with the command:

sudo x11docker --update

How To Use x11docker

With x11docker installed, it’s time to test it out. Let’s test this with the VLC app container. First, pull the image with the command:

docker pull jess/vlc

Once the image has been pulled, run VLC (with the help of x11docker) with the command:

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

You should see the VLC window open, ready to be used (Figure 1). It will be slightly slower than if the media was installed directly on your desktop but, otherwise, it should work as expected.

👁 Image

Figure 1: We’ve launched the VLC media player as a container.

Of course, that doesn’t help much if you’re a developer because you want to develop your own containers. You could always create the image you want to work with, tag it, push it to your repository of choice, pull it to your dev system with the docker pull command, and then deploy the container with x11docker.

And there you have it. You can now run GUI applications from within Docker containers, thanks to x11docker. Build on this by deploying your own, custom containers from your own images and see how it works.

FAQ

Q: What is the main difference between running GUI apps in traditional Linux environments versus using Docker containers?

A: Running GUI apps in traditional Linux environments typically requires installing and configuring specific packages, such as X11 or Wayland. In contrast, using Docker containers allows you to run GUI apps without modifying your host system, making it easier to create and manage isolated environments.

Q: Do I need a separate operating system for running GUI apps with Docker?

A: No, you don’t need a separate operating system for running GUI apps with Docker. You can use the same Linux distribution as your host OS and install necessary packages using Docker containers.

Q: How do I run a GUI app in a Docker container?

A: To run a GUI app in a Docker container, follow these general steps:

  1. Pull the desired image (e.g., docker pull jess/vlc for VLC media player).
  2. Run the image using x11docker or another GUI-specific runtime tool.
  3. Configure any necessary settings, such as shared directories or display output.

Q: What are some common issues when running GUI apps in Docker containers?

A: Some common issues include:

  • Inability to connect to external resources (e.g., USB devices).
  • Lack of proper input/output redirection.
  • Difficulty with keyboard and mouse interactions.
  • Issues with display rendering or scaling.

Q: How do I troubleshoot problems with running GUI apps in Docker containers?

A: Troubleshooting typically involves:

  • Checking the container logs for error messages.
  • Verifying that necessary packages are installed and configured correctly.
  • Ensuring that shared directories are properly set up.
  • Using debugging tools to inspect the application’s behavior.

Q: Can I use x11docker with other Docker runtimes?

A: No, x11docker is specific to running GUI apps using X11. Other Docker runtimes (e.g., –rm –net=none) may not provide the necessary environment for proper GUI app execution.

Q: Are there any performance implications when running GUI apps in Docker containers?

A: Running GUI apps in Docker containers can introduce some overhead due to:

  • Increased process isolation.
  • Higher memory requirements (for shared directories and X11 sessions).
  • Potential network latency.
  • However, the impact on performance is typically minimal compared to running native applications.

Q: Can I use x11docker with other Linux desktop environments?

A: Yes, x11docker can be used with various Linux desktop environments, including:

  • GNOME
  • KDE
  • XFCE
  • LXDE

Just make sure to configure the container properly for your chosen desktop environment.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
Feature Image by Alan Frijns from Pixabay (AI generation)
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.