How to Install Docker CE and Docker-Compose on CentOS 8

Image for post
Image for post

Docker is a set of Platform as a Service (PaaS) products that uses operating system level virtualizations to deliver software in the form of containers. Docker CE (Community Edition) is the strip down version of Docker EE (Enterprise Edition). Docker CE is free and open source and distributed under Apache License 2.0.

In Red Hat Enterprise Linux (RHEL) 8 / CentOS 8, Support of Docker has been removed by the vendor. Whereas a new containerization platform libpod (Podman’s Container Management Library) has been introduced inplace of Docker.

However, we can still install Docker and it’s dependencies on CentOS 8 / RHEL 8 from third party yum repositories.

In this article, we are installing Docker CE and docker-compose on CentOS 8.

Prerequisites

  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get $450 — $1300 worth in Alibaba Cloud credits for your new account. If you don’t know how to setup your ECS instance, you can refer to this tutorial or quick-start guide.
  • A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  • Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  • Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  • Set up your server’s hostname and create a user with root privileges.

Environment Specification

We have configured a CentOS 8 virtual machine with following specifications.

  • CPU — 3.4 Ghz (2 cores)
  • Memory — 2 GB
  • Storage — 40 GB
  • Operating System — CentOS 8.0
  • Hostname — docker-01.example.com
  • IP Address — 192.168.116.6/24

Adding Docker CE yum Repository on CentOS 8:

Connect with docker-01.example.com using ssh as root user.

Docker CE is available to download from Docker’s Official Website However, we can also install it from Docker CE yum repository.

Add Docker CE yum repository using dnf command.

Build cache for Docker yum repository.

Installing Docker CE on CentOS 8:

After addition of Docker CE yum repository, we can now easily install Docker CE on CentOS 8 by using a dnf command.

Docker CE requires containerd.io-1.2.2–3 (or later) package, which is blocked in CentOS 8. Therefore, we have to use an earlier version of containerd.io package.

Install docker-ce with an earlier version of containerd.io using following command.

Enable and start Docker service.

Check status of Docker service.

Check Docker version.

Docker CE has been installed on CentOS 8.

Create a Container using Docker in CentOS 8:

Let’s put Docker into action by creating a simple container.

For this purpose, we are using official image of Alpine Linux from Docker Hub.

Pull Alpine Linux image from Docker Hub.

List locally available docker images.

Create and run a container using Alpine Linux image.

Installing Docker-compose on CentOS 8:

Additionally, we are installing docker-compose on our CentOS 8 server, so we can create and run multiple containers as a single service.

Download docker-compose package from GitHub.

Grant execute permissions to docker-compose command.

Check docker-compose version.

We have successfully installed Docker CE and Docker-Compose on CentOS 8. We have only explored the installation of Docker CE here

Original Source:

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store