TASK:02

TASK:02

Task Description ??

?? GUI container on the Docker

?? Launch a container on docker in GUI mode 

?? Run any GUI software on the container

In this article i will show you to launch a gui container on the docker by two methods , SO lets start ?? :

GUI : Graphical User Interface" also pronounced as "gooey" is a user interface that includes graphical elements, such as windows, icons and buttons to make surfing experience smoother and easier.

How does linux os support GUI?

Underneath the desktop environment, most desktop Linux systems have an implementation of the X Window System, which is the system-level infrastructure for the graphical user interface. Inside this system there is an X server program that runs on a computer with a graphical display and communicates with various client programs. The server accepts requests for graphical output (windows) and sends back user input (keyboard, mouse).

So we can say that linux as a base OS already have Xserver program running on it. But since we know that in docker world , the container is entirely a different OS altogether and to run GUI program on the top of container we dont have x-server. So we need a X server power from base os or we can download the image of that GUI program which we have to run on the top of container .

In this demo I will be showing you to launch gedit and firefox as GUI program to run on docker by two ways i.e by taking access from base os and by downloading the image of firefox repectively.

Environment Requirement : 1- Docker installed

2 - Centos image to be downloaded

No alt text provided for this image

To check all the containers running:

docker ps -a
No alt text provided for this image

general error :No display environment variable specified

No alt text provided for this image


So the environment variable which we have to use is "DISPLAY". Use = This variable is used to indicate to graphical applications where to display the actual graphical user interface. command : --env=DISPLAY. And since we are using the server naming X11 server of base os therefore we have to specify that by using --net=host

No alt text provided for this image

Now install gedit using:(NOTE: in this step i have shifted from putty displayed screen to original redhat display since when i was trying to run the command on screen using putty software then it was throwing certain errors)

yum install gedit
No alt text provided for this image

To run gedit:

No alt text provided for this image

gui:

No alt text provided for this image

Method :02 (Here i will be using firefox gui as a demonstration.)

#step
mkdir sample
cd sample 
vim dockerfile

No alt text provided for this image
No alt text provided for this image

Now we have to build the image of firefox using:(note here (.) stands for current directory location)

docker build -t firefox .

in my case i have already build it so i will be showing you the image straightaway:

docker images
No alt text provided for this image

Now we can a container inside docker using firefox image so so that firefox gui can be displayed. (note: here also we have to define environment variables and host address )

#command 
docker run -it --name=os1 --env="DISPLAY" --net=host firefox
No alt text provided for this image

gui:

No alt text provided for this image

HAPPY LEARNING!

要查看或添加评论,请登录

Anuj Ramola的更多文章

社区洞察

其他会员也浏览了