Running GUI Applications in Docker — Firefox, Nautilus File Manager.

Muhammad Tabish Khanday
Mar 26 · 4 min read

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that the machine might have that could differ from the machine used for writing and testing the code.

In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications to be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.

Types of applications (usually services) that you can containerize:

  • Applications that run as a Background Service (like a Database, WebServer, etc)
  • GUI Applications that run in the foreground.

Today, we are going to see the second option:

X Window System/ X:

X11 is the current version of the X Window System.

X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting with a mouse and keyboard. X does not mandate the user interface — this is handled by individual programs. As such, the visual styling of X-based environments varies greatly; different programs may present radically different interfaces.on Unix-like operating systems.

For a GUI Application to run, we need to have an XServer which is available as part of every Linux Desktop Environment.

Run the following command to see the X Server and X Client running on your Linux Machine:

For Windows, you can use Xming.

For OSX, you can use Xquarkz.

But within a Container, we don’t have any XServer — so we will:

  • Mount the socket residing in on your local machine into in the container.

  • share the Host’s DISPLAY environment variable to the Container

  • run container with host network driver with

Example 1: Dockerfile to build an image with a sample GUI application (Firefox):

Docker Hub:

You should see the firefox GUI application now displayed on your Host OS Desktop.

Example 2: Dockerfile to build an image with a sample GUI application (Nautilus File Manager):

Docker Hub:

You should see the Nautilus GUI application now displayed on your Host OS Desktop.

That’s all for today! I’ll be back with some new articles very soon, thanks! 🤗

Muhammad Tabish Khanday



Everything connected with Tech & Code