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
Add the following content to the repo file:
Run This:
yum repolist
So we have configured Docker repo and now we can install docker by using command:-
yum install docker-ce --nobest
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
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.
Inside dockerfile we will right following code:
FROM centos
RUN yum install firefox -y
CMD ["/usr/bin/firefox"]
Building Dockerfile
We can use the following code to build the docker file-> docker build -t <GUI_IMAGE_Name> <file_path>.
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.
Soon after this your firefox will open up.
Hence we have achieved our task of launching a GUI Container on the Docker.