Install Docker CE on CentOS 8

29/12/2020
Docker CE is officially not supported on Red Hat Enterprise Linux (RHEL) 8 or CentOS 8. The Red Hat’s officially recommended way to manage containers on RHEL 8 and CentOS 8 is Podman. Podman is basically a replacement for Docker on RHEL 8 and CentOS 8. Docker images are compatible with Podman though. So, moving to Podman should not be too hard.

Anyway, this article is not about Podman. It’s about getting Docker installed on CentOS 8. If you really don’t want to switch to Podman and keep using Docker on your RHEL 8 or CentOS 8 machine, then this article is for you.

NOTE: If you’re going to use Docker on a production machine, then I recommend you not to upgrade to CentOS 8/RHEL 8. Keep using CentOS 7/RHEL 7 until Docker has official support for RHEL 8 and CentOS 8.

Installing Required Tools:

First, update the CentOS 8 package repository cache with the following command:

$ sudo dnf makecache

Now, install all the tools required for installing Docker CE with the following command:

$ sudo dnf install dnf-utils device-mapper-persistent-data lvm2
 fuse-overlayfs wget

To confirm the installation, press Y and then press <Enter>.

All the required tools should be installed.

Adding Docker CE Official Package Repository:

Docker CE is not available in the official package repository of CentOS 8. But you can add the official Docker CE package repository on CentOS 8 and install Docker from there.

To add the official Docker CE package repository, run the following command:

$ sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/
docker-ce.repo

Now, update the CentOS 8 package repository cache with the following command:

$ sudo dnf makecache

Installing Containerd.io:

The main incompatibility of Docker CE on RHEL 8 and CentOS 8 is containerd.io package. Docker CE depends on that package, but RHEL 8 and CentOS 8 officially flagged these packages. So, you can’t install the version of containerd.io package that Docker needs to work on RHEL 8 and CentOS 8 using the DNF or YUM package managers directly.

Luckily, we can manually download the latest version of containerd.io package and install it on CentOS 8.

First, navigate to the /tmp directory as follows:

$ cd /tmp

The latest version of containerd.io package is 1.2.6-3.3 at the time of this writing. You may check for a later version when you’re reading this article at https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

Now, download the latest version of containerd.io package from the official CentOS 7 package repository of Docker CE with the following command:

$ wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
containerd.io-1.2.6-3.3.el7.x86_64.rpm

The latest version of containerd.io package should be downloaded.

The containerd.io RPM package file should be in the /tmp directory as you can see in the screenshot below.

$ ls -lh containerd.io*

Now, install the containerd.io-1.2.6-3.3.el7.x86_64.rpm package file using DNF package manager as follows:

$ sudo dnf localinstall ./containerd.io-1.2.6-3.3.el7.x86_64.rpm

To confirm the installation, press Y and then press <Enter>.

The latest version of containerd.io should be installed.

Now, you’re ready to install Docker CE on your CentOS 8 machine.

Installing Docker CE:

To install Docker CE on CentOS 8 from the official Docker CE package repository, run the following command:

$ sudo dnf install docker-ce docker-ce-cli

To confirm the installation, press Y and then press <Enter>.

The DNF package manager should start downloading all the required RPM packages from the Docker CE package repository. It may take a while to complete.

At this point Docker CE should be installed.

Now, check the status of the docker service with the following command:

$ sudo systemctl status docker

The docker service may be inactive (not running) and disabled (won’t auto start on boot) as in my case.

To start the docker service, run the following command:

$ sudo systemctl start docker

Also, to automatically start the docker service on system boot, add the docker service to the system startup of CentOS 8 as follows:

$ sudo systemctl enable docker

Now, check the status of the docker service again.

$ sudo systemctl status docker

The docker service should be active (running) and enabled (will auto start on system boot).

You will not want to run Docker commands with sudo or as root user. In order to run Docker commands as your login user, you must add your login user to the docker group.

To add your login user to the docker group, run the following command:

$ sudo usermod -aG docker $(whoami)

Now, reboot your CentOS 8 machine with the following command:

$ sudo reboot

Once your CentOS 8 machine boots, you can check whether Docker is working with the following command:

$ docker version

As you can see, I am running Docker CE 19.03.5. Docker Engine client and server is also working.

Now, let’s try to run the hello-world Docker container.

$ docker run hello-world

As you can see, Docker pulled the hello-world container from the internet and ran it successfully.

So, that’s how you install Docker CE on CentOS 8. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Managing Docker Volumes using Docker Compose

Purpose of Docker Volumes Docker containers are meant to be a drop-in replacement for applications. They are meant to be...
29/12/2020

7 Tips to Optimize Your Docker Images

7 Tips to Optimize Your Docker Images #1 Design Container Images for a Single Job By focusing a container image for single...
28/12/2020

Docker Overlay Driver and Overlay Networking

Docker comes with three networking drivers by default. Network adapters are also initialized using these drivers, carrying...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024

Dịch vụ thuê mua proxy giá rẻ an toàn, tốc độ cao
13/05/2024

Thuê mua proxy V6 uy tín, chất lượng tại đâu?
11/05/2024

Thuê mua proxy Tiktok tăng doanh thu, hiệu quả cao
11/05/2024