Working with Docker – I

Before installing Docker we need to understand about containers. What do we mean by containers? What is the difference between containers and VM’s? In simple word they will look similar at first, but there are some important differences, as explained below:

VM: To create and run a VMs you required hypervisor. Each VM requires a full copy of the Operating System to run the application and it’s supporting libraries.

Containers: So, this is an approach to virtualization in which the virtualization layer runs as an application within the operating system. In this approach the OS’s kernel run on the hardware node with several isolated guest virtual machines installed on top of it. The isolated guests are called as Containers.

Containers are now changing the way we develop, distribute, and run software. Developers can build their software locally, knowing that it will run identically regardless of host environments. Whereas Operations engineers can only concentrate on networking, resources, and up time and spend less time configuring environments. This will help organizations to shift left. Now a days the use of containers is increasing at a huge rate across the industry, from the smallest start ups to large-scale enterprises.

Prerequisites to install Docker Engine:

Docker supports only latest kernel versions i.e. version 3.10 or above.  You can check your kernel version by running command uname -r .  If you are using RHEL or CentOS, you will need version 7 or later. Also you need to be running on a 64-bit architecture. You can verify your this by running uname -m .

How to install Docker Engine on CentOS/ Fedora/ RHEL:

There are two ways to install Docker Engine.

  1. You can install Docker Engine using yum package manager.
  2. You can install Docker Engine using curl with the get.docker.com site.

The second method runs an installation script which also installs Docker engine via yum package manager. In this post I will use the second method to install Docker engine on my machine.

Step 1: Update your existing packages.

Step 2: Run the Docker installation script.

Step 3: Enable the service.

Step 4: Start the Docker daemon.

Step 5: Verify Docker is installed properly by running a test image in a container.

Create a docker group

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo. For this reason, docker daemon always runs as the root user.

To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

Step 1: Log into your machine as a user with sudo or root privileges.

Step 2: Create the docker group.

Step 3: Add your user to docker group. In my case I will add linuxfunda user to the group

Step 4: Log out and log back in

This ensures your user is running with the correct permissions.

Step 5: Verify that your user is in the docker group by running docker without sudo.

In the next chapter i.e. Chapter-II we will learn few docker basic commands and we will keep continue learning Docker.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

One thought on “Working with Docker – I

Leave a Reply