Running Graphical Process inside Docker Container
Introduction
In this article i am going to enable graphical program inside docker container
By default docker did not supports the graphical program like firefox, chrome one of the reason for this graphical program are generally heavy and use very high cpu and ram and graphical server (program responsible for running graphical program) take high time to boot
But there is some ways we can enable graphic supports inside docker container and in this article i am going you to show the one one of the ways of doing this
Enable Graphical program
to install graphical program inside docker use below command:-
docker run -it --name myos3 --env DISPLAY=unix$DISPLAY --volume=$HOME/.Xauthority:/root/.Xauthority --net=host centos
docker run command is used
it is used so that we can interact with terminal
— name:- is used to give name to the container
— env DISPLAY=unix$DISPLAY:- this variable contain which display we have to use to launch any graphical program
DISPLAY variable contain which display we have use when launching the graphical application
Type echo $DISPLAY
so its show :0
well this means means use 0(display number zero) well its 0 means primary display
so what happen if i change it to somethings like let say 2 well nothing happen it’s gives you the warning like this:-
and gedit is start well the x11 server is smart enough to handle the error so its gives warning and start on default display which is 0.
x11 is the program that is responsible for rendering graphic on the screen in unix like os and the same things is done by Desktop Window Manager(dwm.exe) in windows
— volume=$HOME/.Xauthority:/root/.Xauthority:- .Xauthority is the folder that store the session information of the x11 server
— net=Host:- this line i will explain in later section
see this in action run yum install gedit
command to install gedit
if you run ifconfig command in baseos and container you notice that both have the same number of network cards and configuration and even the ip address is same why is happen like this this happen because of the --net=host
option now both base os and container are sharing same network configuration.
So this is bad actually no this trick we have some times when it’s harder do port forwarding because our application use to many port and in our case we don’t known on which port no x11 server is running in the baseos that why we use this option --net=host
so that we have no problem while launch any number graphical application
Now run gedit
command you can see the gedit launch with many warning like this
well this not affect the actual working of application
Conclusion
The concept I use here is also known as x11 forwarding we the same concept if we want to launch graphical application using ssh there different command and syntax but the concept is same.
Contact Detail
LinkeDin [https://www.linkedin.com/in/suyash-garg-50245b1b7]
Additional Tags
#vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeducation #arthbylw #docker #container #summerintership