Hello everybody , welcome to my new technical blog , In this blog we are going to do an amazing and great practical , the objective of the practical is going to launch gui software on the top of docker container .
As we all know that we can launch any OS using just one simple command with the help of great container technology known as docker . But the problem is we can't launch OS directly where we can run GUI application.
Prerequisites:-
* Configured yum for docker
Introduction of docker :-
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files.
The main motto of Docker is for developers to easily develop(build) applications, ship them into containers after which they can be deployed(run) anywhere.
Why we need GUI Container :-
Now let's see why we need a GUI container , Suppose we want to build any UI app and want to deploy that app on docker container , then in that case we need Gui container . So here we have to connect the display of the Local Machine (Host OS) with the docker container.
Now let's Jump to the practical part
Note :- Make sure docker daemon is running
1) Create dockerfile :-
We are creating dockerfile to build image where we'll enter the required configuration to launch a GUI Container . We'll fetch latest version of CentOS for our Docker Image. To do so, we'll create a workspace ( i.e, "ws" in my case ) and inside that crate one file named as Dockerfile .
Dockerfile :-
FROM centos:latest
RUN yum install firefox gedit -y
ENV firefox /usr/bin/gedit
ENV gedit /usr/bin/firefox
2) Building Docker Container :-
We'll now build the container which will work according to the above Dockerfile. It will install firefox web browser , gedit text editor and its required packages. Here, the image name is set as guiImage, you can name it as your desire.
Command :-
docker build -t roshu308/gui-image:v1 .
From here you can see that our image is builded successfully.
3) Launching Docker Container:-
Now I am going to launch one container by using above create image .
command :-
docker run -it --name gui_os --env="DISPLAY" --net=host
volume="$HOME/.Xauthority:/root/.Xauthority:rw" roshu308/gui-image:v1
Now let's see the live demonstration of above written command and see how the things work.
Conclusion :
So from this blog we come to know , that we can easily launch any gui app and run it from docker conatiner . It is fully dependent on your Docker Container. In this blog , I tried Firefox and Gedit in our CentOS 7 Docker Image . We can try many more GUI Apps.
Thanks For Reading 😎😎
Kommentare