TNS
VOXPOP
Will JavaScript type annotations kill TypeScript?
The creators of Svelte and Turbo 8 both dropped TS recently saying that "it's not worth it".
Yes: If JavaScript gets type annotations then there's no reason for TypeScript to exist.
0%
No: TypeScript remains the best language for structuring large enterprise applications.
0%
TBD: The existing user base and its corpensource owner means that TypeScript isn’t likely to reach EOL without a putting up a fight.
0%
I hope they both die. I mean, if you really need strong types in the browser then you could leverage WASM and use a real programming language.
0%
I don’t know and I don’t care.
0%
Containers / Linux

Run GUI Applications as 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
Featued image for: Run GUI Applications as Containers with 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

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:


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


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


Update apt with:


We can now install Docker with the command:


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:


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:


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

How to Install x11docker

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


Next, install x11docker with the command:


You can then update x11docker with the command:

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:


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


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.

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.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Docker.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.