How to install Docker on Red Hat Enterprise Linux and CentOS Linux 7
In today’s guide lets jump into Docker containerization technology. Docker is an open source software which helps to set up with Container as a service (CaaS). It will covert the operating system as a virtualization platform to run with N numbers of Containers.
- How to install Docker on Red Hat Enterprise Linux and CentOS Linux 7
- How to search for docker images and launch a container
- How to connect Docker containers and expose the network
- How to manage Docker containers
There are two different editions available in docker. They are
- Community Edition (CE)
- Enterprise Edition (EE)
Docker CE is free to use, Our setup will use with CE. Docker EE is same as CE, but it included with commercial support from docker.
Now you may ask what is Container?
Containers are lightweight and they are packed with required libraries to run any applications. Absolutely they are not a Virtual machine.
What is the difference between Virtual machines and Containers?
Virtual machines are built on top of Virtualization software. To have a virtual machine first we need to get a Physical server and install with Virtualization software, on top of it Virtual machine will be created. To deploy with anyone of application we need to create individual virtual machines by defining resources to each VM’s.
Physical Machine –> Hypervisor –> Virtual Machine –> Operating System –> Application
Containers are built on top of the base operating system. We need a physical machine or virtual machine to run a container by installing docker package. We can run any numbers of containers in the same host where docker daemon running on it.
Physical Machine –> Operating System (With Docker) –> Containers
Look at below figure to get more idea how Docker differ from Virtual Machines.
Let’s start to install the Docker. This guide not limited to installing only on RHEL and CentOS its applied for Oracle Linux and Scientific Linux too.
Step 1: Enable docker repositories.
Its good idea we need to install docker from the official repository to resolve all dependencies. Download and save the repo file under /etc/yum.repo.d/.
# cd /etc/yum.repos.d/; curl -O https://download.docker.com/linux/centos/docker-ce.repo
Step 2: Install the Docker package
Now list and verify the repository or just install with the docker package.
# yum repolist # yum install docker-ce -y
Step 3: Start and enable Docker service persistently
Once we have done with installation start and enable the docker service
# sudo systemctl start docker # sudo systemctl enable docker
Step 4: Grant non-root user to run privileged docker commands.
To run the docker commands from unprivileged accounts we need to add the user account in docker group.
In our setup “babinlonston” is the user need to run all docker related commands. Add him to docker group so that he has all privileges to run the docker related commands without switching into the root.
# sudo usermod -aG docker babinlonston
Step 5: Run a few basic Docker commands
Now, let’s verify docker status and version information by running few basic commands.
To print the docker version run
# docker -v
To getting the status information in brief run with
# docker info
That’s it we have completed with installing Docker in RHEL based servers.
We have seen how to enable with a containerization service by installing Docker. It provides CAAS upon installing a package, we can manage micro-services easily than before. It helps developers work more super easy by build, ship and deploy. Let’s continue more topic on docker till then subscribe to our newsletter to receive the up-to-date posts.