Create your first Docker container : A Beginner’s guide
Last updated on March 12th, 2018 at 08:32 pm
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 install it 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.
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,
|$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.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
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,
This was our tutorial on installing docker 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.