GUI Application on Docker Container

Basically, docker has CLI ( Command Line Interface ), Sometimes we may need to make it GUI ( Graphical User Interface ). In this blog, stepwise commands are written to launch a GUI container on docker.

 Step 1: Open the base OS which is RHEL 8 in our case

Step 2: open the terminal

Step 3: Using the command line

docker ps 

Make sure that no other containers are running

In my case no container is running.

Step 4: While starting a new normal ( CLI ) container we use the following command

docker run -it --name nameofos centos:latest

But to launch GUI container we have to run separate command 

docker run -it --net=host --env=DISPLAY --volume=$HOME/.Xauthority:/root/Xauthority centos

This command means
--net=host // It used the host network settings 
--env=DISPLAY //Access the environmental variables for Display
--volume=$HOME………. // copying the graphic cookies and data to container to make the container suitable for GUI applications

As this container uses the host network , therefore there would be same IP of this GUI container and RHEL8 ( our base OS )

When the GUI container is launched there is not change in the root, to check whether the GUI container is launched or not we will use docker ps command

Now the GUI container is successfully launched, Install firefox using the command

yum install firefox

It starts downloading !!

It takes some time to install. 

After installation type 


To run the firefox , which is GUI

In my case, the firefox is opened. 

GUI container successfully launched on docker.

Now lets open jupyter notebook in the container. 

Firstly install python in the GUI container , using the following command

Yum install python3

And after that , install jupyter notebook

pip3 install jupyter –allow-root

And finally to open jupyter notebook click

Jupyter notebook –allow-root

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *