In this guide we’ll be walking you through the steps of installing Docker CE on CentOS 8 | RHEL 8. We’ll also cover how to install Docker Compose on RHEL 8 / CentOS 8 Linux?. Docker is not officially supported on RHEL 8 as it has been replaced with Red Hat tools – buildah and podman. You can learn more about new features witnessed in release of RHEL 8 Linux.
But what if you use Docker every single day and can’t switch to buildah and podman immediately?, don’t worry since there is a way to install Docker and Docker Compose on RHEL 8 / CentOS 8. Docker is a tool that enables you to create, deploy and run your applications in containers. Containers allow a Developer to package an application with its dependencies and ship it out as a single package. Containers are often used in Microservices environments.
Docker Components / Terminologies
There area a number of Docker specific jargon that we need to clarify before diving into installation and usage examples. Below are commonly used terminologies in Docker ecosystem.
- Docker daemon: This is also called Docker Engine, it is a background process which runs on the host system responsible for building and running of containers.
- Docker Client: This is a command line tool used by the user to interact with the Docker daemon.
- Docker Image: An image is an immutable file that’s essentially a snapshot of a container. A docker image has a file system and application dependencies required for running applications.
- Docker container: This is a running instance of a docker image with an application and its dependencies. Each container has a unique process ID and isolated from other containers. The only thing containers share is the Kernel.
- Docker registry: This is an application responsible for managing storage and delivery of Docker container images. It can be private or public.
Install Docker CE on CentOS 8 | RHEL 8
So far we have covered docker introduction and terminologies. We should be ready to install Docker CE on RHEL 8 / CentOS 8. We will start with the installation of Docker then Docker Compose.
There are two editions of Docker available.
- Community Edition (CE): ideal for individual developers and small teams looking to get started with Docker and experimenting with container-based apps.
- Enterprise Edition (EE): Designed for enterprise development and IT teams who build, ship, and run business-critical applications in production at scale.
The Docker Enterprise Edition requires an active license to use. In this guide, we will install Docker CE on RHEL 8. Let’s add Docker repository before we can install it.
sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
This command will download Docker repository file
### CentOS 8 ### $ sudo yum makecache Updating Subscription Management repositories. Updating Subscription Management repositories. Docker CE Stable - x86_64 6.1 kB/s | 14 kB 00:02 Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta (RPMs) 1.8 kB/s | 4.1 kB 00:02 Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta (RPMs) 3.5 kB/s | 4.1 kB 00:01 Metadata cache created. ### RHEL 8 ### $ sudo yum makecache Updating Subscription Management repositories. Docker CE Stable - x86_64 14 kB/s | 3.8 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 33 kB/s | 2.8 kB 00:00 Red Hat Ansible Engine 2.8 for RHEL 8 x86_64 (RPMs) 29 kB/s | 2.4 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 30 kB/s | 2.4 kB 00:00 Red Hat Satellite Tools 6.6 for RHEL 8 x86_64 (RPMs) 29 kB/s | 2.1 kB 00:00 Metadata cache created.
Finally install Docker CE by running the command below in your terminal.
sudo yum install docker-ce
If you get dependency issues with Podman allow errasing.
sudo yum install docker-ce --allowerasing
Agree to install by hitting the y key in your keyboard:
Dependencies resolved. ===================================================================================================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================================================================================================== Installing: docker-ce x86_64 3:19.03.13-3.el8 docker-ce-stable 24 M Installing dependencies: containerd.io x86_64 1.3.7-3.1.el8 docker-ce-stable 29 M replacing runc.x86_64 1.0.0-66.rc10.module+el8.2.1+6465+1a51e8b6 docker-ce-cli x86_64 1:19.03.13-3.el8 docker-ce-stable 38 M libcgroup x86_64 0.41-19.el8 rhel-8-for-x86_64-baseos-rpms 70 k Removing dependent packages: podman x86_64 1.9.3-2.module+el8.2.1+6867+366c07d6 @rhel-8-for-x86_64-appstream-rpms 60 M Transaction Summary ===================================================================================================================================================================================================== Install 4 Packages Remove 1 Package Total download size: 92 M Is this ok [y/N]: y
Import GPG key as well.
Total 21 MB/s | 92 MB 00:04 warning: /var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Docker CE Stable - x86_64 29 kB/s | 1.6 kB 00:00 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 and enable Docker Service to start at boot.
$ sudo systemctl enable --now docker Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
The docker service status should indicate running.
$ systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2020-10-06 17:05:53 EAT; 2min 32s ago Docs: https://docs.docker.com Main PID: 230185 (dockerd) Tasks: 13 Memory: 41.4M CGroup: /system.slice/docker.service └─230185 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
docker group is created, but no users are added to the group. Add your user to this group to run docker commands without sudo
$ sudo usermod -aG docker $USER $ id $USER uid=1000(jmutai) gid=1000(jmutai) groups=1000(jmutai),10(wheel),984(docker)
Logout and Login again to use Docker without sudo. The version of Docker installed can be checked with:
$ newgrp docker $ docker version Client: Docker Engine - Community Version: 19.03.13 API version: 1.40 Go version: go1.13.15 Git commit: 4484c46d9d Built: Wed Sep 16 17:02:36 2020 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.13 API version: 1.40 (minimum version 1.12) Go version: go1.13.15 Git commit: 4484c46d9d Built: Wed Sep 16 17:01:11 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.3.7 GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683
Pull Test docker image
The last step is to test your installation by downloading a test docker container.
$ docker pull alpine Using default tag: latest latest: Pulling from library/alpine 8e402f1a9c57: Pull complete Digest: sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0 Status: Downloaded newer image for alpine:latest
List downloaded images.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest 5cb3aa00f899 2 days ago 5.53MB
hello-world latest fce289e99eb9 2 months ago 1.84kB
Verify that Docker CE is working correctly by running the alpine container from downloaded image.
$ docker run -it --rm alpine /bin/sh
/ # apk update
OK: 9754 distinct packages available
/ # exit
Install Docker Compose on CentOS 8 | CentOS 8
We have Docker installed and running, let’s now change gear to Docker Compose. Docker Compose is a tool used to define and run multi-container Docker applications.
The application services are configured using a Compose file. Unlike running docker commands, a single command is all that’s required to create and start all the services from your configuration. Docker Compose is a great tool for development, testing, and staging environments, as well as CI workflows.
Install Docker Compose on RHEL 8 / CentOS 8
Follow our separate guide on installation of latest Docker Compose on Linux.
Install Docker UI – Optional
If you need Docker management UI which allows you to easily manage your different Docker hosts and containers, please give Portainer a try. It is easy to install and use.
Monitoring Docker containers
Monitoring Docker containers can be achieved by using Monitoring tools such as Netdata or Ctop or Prometheus and Grafana. Below guides should be helpful.