Launching GUI application on Docker

Richard nadar
3 min readMay 10, 2021

Docker is a container technology through with OS can be launched just in 1 second, and any CLI command can be easily run on a docker container. But when it comes to GUI programs/applications those cant be run directly and to run them one extra step is required which we are going to see.

Task Description:

  1. GUI container on the Docker
  2. Launch a container on docker in GUI mode
  3. Run any GUI software on the container

STEP 1:

We need to configure docker in our base OS in my case it is Redhat 8, so first we need to configure yum repository for configuring Docker. Go to “/etc/yum.repos.d” folder and create a file with any name and (.repo) extension. Then write the below content.

STEP 2:

After configuring yum repo, we have to download docker engine software using the following command:

# yum install docker -y

After this, we have to start docker services

# systemctl start docker

STEP 3:

We will now pull centos image from docker hub in our base OS.

# docker pull centos:latest

STEP 4:

Now we need to build a custom image for our requirement and for that i am going to write a Dockerfile. First I created a workspace and inside that i created a Dockerfile as shown below.

The contents of Dockerfile are:

STEP 5:

Time to build the image using this Dockerfile, for this we will use the following command:

# docker build -t <image_name> .

(here . means the current folder where Dockerfile is present or we can give the path)

STEP 6:

Lets check whether image is created or not.

STEP 7:

This step is very important. Here we are going to launch a container as soon as it starts firefox application will start. To make this happen, while launching we have to export one environmental variable called “DISPLAY” as shown in the below command.

# docker run -it — name <os_name> — env DISPLAY — net host <image_name>

OUTPUT:

THANK YOU.

--

--