Docker is a containerization technology that allows you to quickly build, test and deploy applications as portable, self-sufficient containers that can virtually run everywhere.
In this tutorial we’ll go through how to install Docker CE on CentOS 7 and explore the basic Docker concepts and commands.
Prerequisites
Before proceeding with this tutorial, make sure that the following prerequisites are met:
- CentOS 7 server
- You have non-root user with sudo privileges. You check this guide about how create a new sudo user.
Install Docker on CentOS
Although the Docker package is available in the official CentOS 7 repository it may not always be the latest version. The recommended approach is to install Docker from the Docker’s repositories.
To install Docker on your CentOS 7 server follow the steps below:
-
Start by updating your system packages and install the required dependencies:
Copysudo yum updatesudo yum install yum-utils device-mapper-persistent-data lvm2
-
Next, run the following command which will add the Docker stable repository to your system:
Copysudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
-
Now that the Docker repository is enabled, install the latest version of Docker CE (Community Edition) using yum by typing:
Copysudo yum install docker-ce
-
Once the Docker package is installed, start the Docker daemon and enable it to automatically start at boot time:
Copysudo systemctl start dockersudo systemctl enable docker
-
To verify that the Docker service is running type:
Copysudo systemctl status docker
The output should look something like this:
Copy● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2018-10-31 08:51:20 UTC; 7s ago Docs: https://docs.docker.com Main PID: 2492 (dockerd) CGroup: /system.slice/docker.service ├─2492 /usr/bin/dockerd └─2498 docker-containerd --config /var/run/docker/containerd/containerd.toml
-
At the time of writing, the current stable version of Docker is
18.06.1
, to print the Docker version type:
Copydocker -v
Docker version 18.06.1-ce, build e68fc7a