GUI Container on the Docker

GUI Container on the Docker

What is 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; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.

Configure Yum Repo and Download Docker

In-order to to install Docker in the OS(in my case, REDHAT), we need to create a docker repo file in /etc/yum.repos.d directory.

vim /etc/yum.repos.d/docker.repo

1 make docker.repo.png

Add the following content to the repo file:

2 add url to repo.png Run This:

yum repolist

So we have configured Docker repo and now we can install docker by using command:-

yum install docker-ce --nobest

3 install docker.png Here, ce in the last stands for Community Edition which is free to use.

Download Docker Image

Now Docker container uses Docker images, we can download docker image like this (in my case i have preinstalled image, but it will download the centos image if you run the command for first time):

docker pull centos:8

4 pull image.PNG

Create Docker File

A Dockerfile is a text file that contains all of the commands that a user could use to create an image from the command line. Users can use docker build to automate a build that executes numerous command-line instructions in a row. We will be creating a Docker file.

5 vim docker file.png

Inside dockerfile we will right following code:

FROM centos
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]

6 dockerfile edit.png

Building Dockerfile

We can use the following code to build the docker file-> docker build -t <GUI_IMAGE_Name> <file_path>.

7 build gui_image.png

Docker container making using gui_image

Now create the docker container : docker run -it --env="DISPLAY" --net=host <image_name>. Make sure to keep the environment variable to be DISPLAY as it is a GUI application.

9 run gui_image.png

Soon after this your firefox will open up.

10 output.png

Hence we have achieved our task of launching a GUI Container on the Docker.