Introduction
Docker is a popular software package that creates and manages containers for application development.
The platform creates a uniform interface so that almost any application running on it is compatible with most operating systems. Developing in Docker also speeds up applications, since it shares the kernel and other Linux resources.
This is a guide on how to install Docker on CentOS 7.
High-Performance Dedicated Servers Starting at Only $199 $90.00/mo
Prerequisites
- A maintained/supported version of CentOS (Docker doesn’t test or support outdated versions)
- A user account with sudo privileges
- Terminal access (Right-click desktop, click Open in Terminal)
- CentOS Extras repository – this is enabled by default, but if yours has been disabled you’ll need to re-enable it
- Software package installer yum
Installing Docker on CentOS 7 With Yum
Installing from Docker repositories using the yum command is the easiest and most popular method.
Step 1: Update Docker Package Database
In a terminal window, type:
sudo yum check-update
Allow the operation to complete.
Step 2: Install the Dependencies
The next step is to download the dependencies required for installing Docker.
Type in the following command:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
The –y switch indicates to the yum installer to answer “yes” to any prompts that may come up. The yum-utils switch adds the yum-config-manager. Docker uses a device mapper storage driver, and the device-mapper-persistent-data and lvm2 packages are required for it to run correctly.
Step 3: Add the Docker Repository to CentOS
To install the edge or test versions of Docker, you need to add the Docker CE stable repository to your system. To do so, run the command:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
A stable release is tested more thoroughly and has a slower update cycle. On the other hand, Edge release updates are more frequent but aren’t subject to as many stability tests.
Note: If you’re only going to use the stable release, don’t enable these extra repositories. The Docker installation process defaults to the latest version of Docker unless you specify otherwise. Leaving the stable repository enabled makes sure that you aren’t accidentally updating from a stable release to an edge release.
Step 4: Install Docker On CentOS Using Yum
With everything set, you can finally move on to installing Docker on CentOS 7 by running:
sudo yum install docker
The system should begin the installation. Once it finishes, it will notify you the installation is complete and which version of Docker is now running on your system.
Your operating system may ask you to accept the GPG key. This is like a digital fingerprint, so you know whether to trust the installation.
The fingerprint should match the following format:
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
Outlet Servers Starting at Only $30.00/mo
Step: 5 Manage Docker Service
Although you have installed Docker on CentOS, the service is still not running.
To start the service, enable it to run at startup. Run the following commands in the order listed below.
Start Docker:
sudo systemctl start docker
Enable Docker:
sudo systemctl enable docker
Check the status of the service with:
sudo systemctl status docker
0
Install a Specific Version of Docker on CentOS
To install a specific version of Docker, start by listing the available releases.
Type the following in your terminal window:
yum list docker-ce --showduplicates | sort –r
The system should give you a list of different versions from the repositories you have enabled above.
Install the selected Docker version with the command:
sudo yum install docker-ce-<VERSION STRING>
The <VERSION STRING>
is found in the middle column and is the first part of the alphanumeric code before the hyphen.
Conclusion
Docker installation on CentOS 7 is a bit easier than installing on Ubuntu.
If you followed this guide, you should have successfully installed Docker on your CentOS 7 machine. Now you can explore the wonderful world of Docker.
Next you should also read
SysAdmin,DevOps and Development,Virtualization
How to Install Docker on Raspberry Pi
December 12, 2019
If you want to install Docker on Raspberry Pi, that is on its Raspian system, you need to use the automated…
How to Install phpMyAdmin on CentOS 7
October 22, 2018
This guide is for users who have already configured a CentOS server and installed the Apache HTTP services,…
How to Install MySQL 8.0 in Ubuntu 18.04
December 12, 2018
MySQL is an open-source relational database server tool for Linux operating systems. It is widely used in…
How to Manage Docker Containers? Best Practices
January 29, 2019
With Docker Container Management you can manage complex tasks with few resources. Learn the best practices of…
SysAdmin,DevOps and Development,Virtualization
How to Install Kubernetes on Ubuntu 18.04
April 15, 2019
Kubernetes is a management platform for Docker containers. Docker lets you create containers for a…
What is Kubernetes? Complete Guide
February 25, 2020
If you are using Docker, you need to learn about Kubernetes. It is an open-source container orchestration…
Author
Sofija Simic
Sofija Simic is an aspiring Technical Writer at phoenixNAP. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.