DEV Community

Cover image for Run GUI apps in docker container.
bhat sumair
bhat sumair

Posted on

Run GUI apps in docker container.

Hello learners,
Today i got a new task how to run GUI applications in container.
we known that by default we can't run GUI applications in docker container because of non-availability of xserver which is required to meet this challenge.
let me show you how to overcome with this challenge:-
Follows these instructions carefully
Install docker in your os
-yum install docker-ce
start docker services
-systemctl start docker
Alt Text
Now pull any image you want in my case i pulled centos latest one
-docker pull centos:latest
It is already in my system you can download it from above command.
Alt Text
launch the docker container with following options.
-docker run -it --net=host --env="DISPLAY" centos:latest
here i pass --net=host means i want to use host connectivity and provide an --env to share docker's host display.
Alt Text
After successffully launch of docker container install firefox
-yum install firefox -y
Alt Text
Now run firefox command
-firefox
so you see it runs successfullyđź‘Ť
Alt Text
Now we can run jupyter notebook
install python
-yum install python3
install jupyter notebook
-pip3 install jupyter
After successfully installed launch jupyter notebook
-jupyter notebook
it shows some error so we have to bypass it with root permission
jupyter notebook --allow-root
Alt Text
Finally it is launched successfullyđź‘Ť
Alt Text
Thanks for reading.

Top comments (0)