Install Docker in CentOS and RHEL 7/6

Install Docker in CentOS and RHEL 7/6

We will discuss Docker, is an open-source lightweight virtualization tool which runs at top of Operating System level, allowing users to create, run and deploy applications, encapsulated into small containers.

This type of Linux containers is proven to be fast, portable and secure. The processes that run in a Docker container are always isolated from the main host, preventing outside tampering.

This tutorial provides a starting point on how to install Docker, create and run Docker containers on CentOS/RHEL 7/6, but barely scratches the surface of Docker.

Step 1: Install and Configure Docker

Docker binaries are incorporated into RHEL/CentOS 7 extras repositories, the installation process being pretty simple. Install Docker package by issuing the following command with root privileges:

Install Docker on RHEL and CentOS 7

yum install docker

Install Docker on RHEL and CentOS 6

# yum install epel-release

# yum install docker-io

After, Docker package has been installed, start the daemon, check its status and enable it system-wide using the below commands:

On RHEL/CentOS 7

# systemctl start docker

# systemctl status docker

# systemctl enable docker

On RHEL/CentOS 6

# service docker start

# service docker status

# chkconfig docker on

Finally, run a container test image to verify if Docker works properly, by issuing the following command

# docker run hello-world

If you can see the below message, then everything is in the right place.

“Hello from Docker. This message shows that your installation appears to be working correctly.”

Now, you can run a few basic Docker commands to get some info about Docker:

For system-wide information on Docker

# docker info