Another popular Linux distribution is CentOS, which is a free, enterprise-class distribution that is compatible with Red Hat Enterprise Linux (RHEL). Go through the following easy recipe to install Docker on CentOS 7.x.
Installing Docker on CentOS
Getting ready
The centos-extra repository must be enabled. This is usually enabled by default, but if you disabled it, please enable it again.
Previously, the Docker package had a different name: It was called docker or docker-engine; it is now called docker-ce. We will need to remove any previous Docker versions in order to prevent any conflicts:
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
It is OK if yum reports that none of these packages are installed.
How to do it...
Go through the following steps:
- Install the required packages:
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
- Set up the Docker yum repository using the stable channel:
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
- Optional: Enable the test channel for access to the nightly builds:
$ sudo yum-config-manager --enable docker-ce-test
- Install the latest version of docker-ce:
$ sudo yum install docker-ce
- If prompted to accept the GPG key, verify that it matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. If it does, then accept it:
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <[email protected]>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
- Start the Docker daemon:
$ sudo systemctl start docker
- Verify that the installation worked:
$ docker container run hello-world
How it works...
The preceding recipe installs Docker on CentOS and all the packages required by it.
There's more...
The default Docker daemon configuration file is located at /etc/docker, which is used while starting the daemon. Here are some basic operations:
- To start the service, enter the following:
$ sudo systemctl start docker
- To verify the installation, enter the following:
$ docker info
- To update the package, enter the following:
$ sudo yum -y upgrade
- To enable the service start at boot time, enter the following:
$ sudo systemctl enable docker
- To uninstall Docker, enter the following:
$ sudo yum remove docker-ce
- To stop the service, enter the following:
$ sudo systemctl stop docker
See also
For more information, check out the CentOS installation document on the Docker website at https://docs.docker.com/install/linux/docker-ce/centos/.