Running GUI Applications in Docker Container.

In this article, we are going to launch a GUI application in the Docker container. According to your use case, you can run any GUI application inside docker. In my case, I am using the Firefox web browser application.

Pre-requisite: Docker should be installed in your virtual machine.

Create customized docker image:

Let's say we want to run any application inside the docker container process. So, first, we have to install the software. Instead of installing every time when we create a container process. We can create a customized container image that has the software. This process is called creating a customized docker image or docker build. For this, the best approach to create an image is “Dockerfile”.

The name of the Dockerfile (Default is ‘PATH/Dockerfile’) but if you want to change you can pass file name with option -f and path


FROM centos:latest
RUN yum install firefox -y
RUN yum install gedit -y

To build image

docker build -tag <imagename:version> path

To run any GUI application

we need Xserver which is available in every Linux desktop environment and containers don't have it. So we need to share it from the base operating system

1.We need to run the container with the host network driver


2. We need to share the DISPLAY environmental variable to the container


3. Share hosts Xserver by creating container volume.


That all we have to do.

follow me for more technological articles.

Thank you for reading...

Aspiring Cloud DevOps Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store