Table of Contents
In today’s guide lets jump into Docker Container or containerization technology. It 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.
- Install Docker on Red Hat Enterprise and CentOS Linux 7
- Search for Docker images and launch a container
- Connect Docker containers and expose the network
- How to manage Docker containers
- Managing Docker data persistently by attaching a volume
There are two different editions available. 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 is included with commercial support.
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 of 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: Resolve Dependencies for Docker Container
Before starting with any installation make sure to resolve the dependencies.
# yum install -y yum-utils device-mapper-persistent-data lvm2
Once resolved the dependencies start the docker installation by enabling the repository.
Step 2: Enable repositories for Docker Container
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 3: Install Docker Package
Now list and verify the repository or just install the package.
# yum repolist # yum install docker-ce docker-ce-cli containerd.io -y
Step 4: Start and enable the service persistently
Once we have done with the installation start and enable the service
# sudo systemctl start docker # sudo systemctl enable docker
Step 5: Grant non-root user to run privileged 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 commands without switching into the root.
# sudo usermod -aG docker babinlonston
Step 6: Run a few basic commands
Now, let’s verify the status and version information by running a few basic commands.
To print the version run
# docker -v
To get the status information in the brief run with
# docker info
That’s it we have completed with installing Docker on RHEL based servers.
We have seen how to enable a containerization service using 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.