GUI APPLICATION ON DOCKER

Ishika singh 19BCS048
3 min readJun 1, 2021

What is docker?

Docker is a software that is based on containerization. It is an open platform for deploying, developing, and managing containers. To make the deployment faster docker only supports CLI( Command Line Interface ). But in some cases developer needs to run some GUI (Graphical User Interface ).

X Server is an architecture-independent system for the graphical user interface. X Service provides the GUI environment. In Linux, we already have X-Server that is called by other programs to provide the GUI.

So, now we know that by sharing X-Server privileges one can run GUI applications on top of Docker Containers.

Task Time

✏️Step-1:-

Every $DISPLAY has a number associated that tells where GUI services are running. This will help us with containers to share the same graphical environment.

echo $DISPLAY

✏️Step-2:-

Now we need to export $DISPLAY services so that they can be used remotely(by containers )

export DISPLAY=:0

✏️Step-3:-

By running “xhost+” our programs are allowed to access display

xhost+

✏️Step-4:-

We create a separate directory for creating docker images.

mkdir images

cd images

✏️Step-5:-

Now we create a “Dockerfile” that helps us to pre-install services like Python3 firefox.

vim Dockerfile

Inside the Dockerfile the code returm.

FROM centos
RUN yum install firefox -y
RUN yum install python -y

CMD /usr/bin/firefox

✏️Step-6:-

Now building the image we have created.

docker build -t guicontainer:v1 .

✏️Step-7:-

Launch the container by using the image we have created and providing additional information regarding the environmental and network host settings.

docker run -it --env=” display” --net=host --name task2 guicontainer:v1

Finally, the GUI application is lunch on the container

--

--