In today’s guide lets jump into Docker 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.
- How to install Docker on Red Hat Enterprise 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
- 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 it 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: 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 the package.
# yum repolist # yum install docker-ce -y
Step 3: 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 4: 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 5: 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 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 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.