How to Run GUI apps using Docker

0 Comments
Editor Ratings:
User Ratings:
[Total: 2 Average: 1]




This tutorial explains how to run GUI apps using Docker. Here in this post, I will talk about a powerful tool which lets you securely run GUI applications such as browsers, media players, and even complete desktop environments on top of Docker. The tool is called x11docker and it basically utilizes an additional X server to run the apps that has a graphical user interface.

So far now, you could only run CLI apps and services through Docker in virtualized containers. But now, with the help of x11docker, you can even run GUI apps. You can run apps like Tor Browser or Ungoogled Chromium in a virtual container without having to install or configure a virtual machine. The plus point here is that, Docker container exhausts less system resources than a VM.

Right now, you can only run x11docker on Linux natively. It supports Windows though, but that implementation is kind of experimental. On macOS, you can’t run it natively, but you can use Linux VMs to try it. There are ready-made docker images for Linux desktop environment and popular desktop apps available. Or, you can even build your own and run them with ease.

x11docker is primarily a command line tool, but the developer has released a GUI version of it as well. This is open source as well and offers an option to share a host folder for the app you want to run using it. For example, if you want to run VLC, then you can share the host system’s Video folder to import and play videos from it.

Run GUI apps using Docker

How to install x11docker on Linux?

You simply start by installing x11docker. There is single command to install it and there are 2 ways. If you use sudo then you just run the following command, given that Docker and cURL are installed.

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

If you are root then simply run the command below.

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

There is a third way as well, that is using a GUI for x11docker. The GUI is included in the installation, and you can just run the “x11docker-gui” command in the terminal to bring it up. The GUI looks like as shown below.

x11docker

Now, you have successfully installed x11docker, it is time to use it.

How to install x11docker on Linux to run GUI apps using Docker?

There are some example docker files available on the profile of the developer of this tool. You can run some simple and commonly known apps such as Tor Browser. The basic syntax to run a GUI app using x11docker is:

 x11docker [OPTIONS] -- IMAGE [COMMAND [ARG1 ARG2 ...]]

So, to run the Tor Browser, you simply run the following command. Give it some time to fetch the required files, and then you will see the starting page of TOR. You can see this in the screenshot below. This instance of TOR browser is running in a Docker container and isolated from the host system. So, it is kind of a sandboxed TOR.

x11docker jess/tor-browser

x11docker tor browser

There is an option in it to even run the apps by sharing a host folder. For example, you can use VLC here and after running VLC, you probably want to run some videos. So, you will have to share a host folder to import files to play. If you don’t do that, then VLC won’t be able to locate the file on the host system. To run VLC with a shared host folder, you use the following command.

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

Tor Browser x11docker

In the screenshot above, you can see VLC running inside a Docker container. It works just like the normal VLC player installed on your PC. You can play anything and it will work just fine.

In this way, you can use this simple and powerful tool to run GUI based apps inside Docker containers. Just follow the process I have mentioned here and you will be all good to go. However, the Docker images available for GUI apps are somewhat limited, but if you have technical knowledge then you can always build your own Docker images corresponding to a GUI based program or app.

Closing thoughts:

If you work with Docker containers, then you will find x11docker to be an amazing tool. In this tool, I have tried to scratch its surface to demonstrate what it is, what it does, and how to use it. You can head to the GitHub page for more detailed technical documentation.

Editor Ratings:
User Ratings:
[Total: 2 Average: 1]
Free/Paid: Free

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer