How to Install Docker CE on CentOS 8 / RHEL 8

Docker is a daemon-based container engine which allows us to deploy applications inside containers. With the release of RHEL 8 and CentOS 8, docker package has been removed from their default package repositories, docker has been replaced with podman and buildah.

Install-Docker-CE-CentOS8

If are comfortable with docker and deploy most the applications inside the docker containers and does not want to switch to podman then this tutorial will guide you on how to install and use community version of docker on CentOS 8 and RHEL 8 system.

Docker is available in two versions,

  • Docker CE (Community Edition)
  • Enterprise Edition (EE)

In this guide we will learn how to install Docker CE (Community Edition) on CentOS 8 or RHEL 8 Server.

System Requirements for Docker CE

  • Minimal CentOS 8 / RHEL 8
  • Sudo or root privileges
  • Internet Connection

Installation Steps of Docker CE on CentOS 8/RHEL 8 Server

Step:1) Enable Docker CE Repository

As we said above, docker packages are not available anymore on CentOS 8 or RHEL 8 package repositories, so run following dnf command to enable Docker CE package repository.

[[email protected] ~]# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Step:2) Install Docker CE using dnf command

Once the docker ce repo has been configured successfully then run following command to verify which version of docker is available for installation

[[email protected] ~]# dnf list docker-ce
Available Packages
docker-ce.x86_64              3:19.03.5-3.el7                    docker-ce-stable
[[email protected] ~]#

Now, use beneath dnf command to install latest version of docker,

[[email protected] ~]# dnf install docker-ce --nobest -y

After the installation of docker, start and enable its service using the following systemctl commands

[[email protected] ~]# systemctl start docker
[[email protected] ~]# systemctl enable docker

Run the following command to verify installed docker version

[[email protected] ~]# docker --version
Docker version 18.06.3-ce, build d7080c1
[[email protected] ~]#

Step:3) Verify and test Docker CE Engine

To verify whether docker ce engine has been setup correctly or not, try to spin up a “hello-world” container using below docker command,

[[email protected] ~]# docker run hello-world

Output of above command

hello-world-container-centos8

As we can see the informational message in above output which confirms docker engine is setup correctly on CentOS 8 / RHEL 8 Server. Let’s move to docker compose installation.

Step:4) Install Docker Compose

As we know that docker compose is used to link multiple containers using a single command. In other words, Docker Compose is useful where we need to launch multiple containers and these containers depends on each other. Examples like launching LAMP/ LEMP applications (WordPress & Joomla etc) insider containers.

Run the following commands to install docker compose on CentOS 8 / RHEL 8,

[[email protected] ~]# dnf install curl -y
[[email protected] ~]# curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Note: Replace “1.25.0” with docker compose version that you want to install but at this point of time this is the latest and stable version of docker compose.

Set the executable permission to docker-compose binary

[[email protected] ~]# chmod +x /usr/local/bin/docker-compose

Verify the docker compose version by running the following command.

[[email protected] ~]# docker-compose --version
docker-compose version 1.25.0, build 0a186604
[[email protected] ~]#

That’s all from this tutorial, I hope these steps help you to setup docker and docker compose on CentOS 8 and RHEL 8 server. Kindly share your feedback and comments in the comments section below.

Read Also : How to Run Containers with Podman on CentOS 8 / RHEL 8

Read Also: How to Use docker-compose to launch containers

7 Responses

  1. Fernando says:

    thanks
    Very usefull

  2. Gunnar Thielebein says:

    Update from my site. I get docker installation suceeded in centos8 after removing podman, like it was suggested.
    Thanks anyone for the tips.

    To get docker compose (e.g. awx) running with external access to the website it was neccessary to enable NAT on the firewall level. This was suggested from Michael Kofler in his german Blog [1].

    firewall-cmd –zone=public –add-masquerade –permanent
    firewall-cmd –reload

    ‘https://kofler.info/docker-unter-centos-8-und-fedora-31-installieren/’

  3. ClancyDamon says:

    Thank you Marcos! That was my problem. The instructions in this article worked like a charm after removing podman.

  4. Vaidya Bala says:

    Hi

    Great How-to. Big fan of the site. However, following these steps as root means, we need to do sudo everytime we want to run docker. It is best to add the normal user to the docker group. May be adding those steps to this howto will make it complete.

    Here is what i am referring to: https://docs.docker.com/install/linux/linux-postinstall/

  5. Marcos Riso says:

    Hi Pradeep, I discovered what was the Gunnar’s problem, first you must remove podman from the system with
    sudo yum remove podman
    Then it will work fine!

    Regards

  6. Pradeep Kumar says:

    Hi Gunnar,

    After configuring the Docker CE repository , run the following to install docker-ce package

    # dnf install docker-ce –nobest -y

  7. Gunnar Thielebein says:

    This guide is incorrect for Centos8.
    The official docker repositories only ship Centos-7 packages for docker-ce.

    Installing docker-ce within Centos-8 fails with an error message:

    sudo -E dnf install docker-ce
    Last metadata expiration check: 0:02:14 ago on Wed 29 Jan 2020 06:13:57 AM EST.
    Error:
    Problem: package docker-ce-3:19.03.5-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
    – cannot install the best candidate for the job
    – package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
    – package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
    – package containerd.io-1.2.2-3.el7.x86_64 is excluded
    – package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
    – package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
    – package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
    (try to add ‘–skip-broken’ to skip uninstallable packages or ‘–nobest’ to use not only best candidate packages)

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest