Docker containers are making news for some time now & there popularity has been growing day by day. They are now being adopted at a fast pace & are replacing Virtual machines especially when it comes to application development. In this tutorial, we will discuss what a Docker container is & will also learn the process to create Docker container on RHEL/CentOS 7.

A Docker container provides a way to run multiple isolated systems on a single server or host. Each container shares kernel (& libraries also) of the host’s operating system. And since each container that is being used, shares OS with host, it makes docker containers very light in size. In-fact size of a Docker container can be in Megabytes (not GBs) & they load up extremely faster in mere seconds as compared to virtual machines that are GBs in size & take minutes not seconds to load up.

Now let’s start with the installation of Docker container.

Recommended Read: Important Docker commands for Beginners

Also Read: Create & manage docker hosts with Docker Machine on VirtualBox

 


Create Docker Container


Installation

Docker is available on Centos-Extras repository for CentOS only & on Epel-repository for both RHEL & CentOS 7. So firstly, we will add epel repository on the system by running the following,

For CentOS/RHEL 8, run,

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

For CentOS/RHEL 7, use the following command,

$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

Once the repository has been installed, we can simply install docker by using yum,

$ yum install docker

Next, start the services for docker,

$ systemctl start docker
$ systemctl enable docker

 

Configuring Docker

We will now download an official image of Centos for Docker. To do so, run

$ docker pull centos

This will download official images for Centos & depending on internet speed & size of iso file, it can take some time. We can also download official images of Ubuntu or fedora using the same command as above, by replacing Centos with Ubuntu or fedora.

Next we will verify the downloaded images by running the following command,

$ docker images centos

 

Creating a Docker container

Now that we have our images, we will create a container. To create a docker container, run

$ docker run –it centos /bin/bash

Here, ‘-it’ will allocate a terminal to created container. To check the running containers in the system, run

$ docker ps

Once we have completed work on container, we can exit out of the container by typing,

$ exit

This was our tutorial on install & create docker container on  RHEL/CentOS 7. In our future tutorials, we will discuss docker in bit more detail. That’s it for now, please leave your questions & comments on the comment box below.

 

 

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Become a Supporter - Donate us some of you hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.