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

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

Note : Run below dnf command to apply all the available updates and then reboot

# dnf update -y ; reboot

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.

[root@docker-ce ~]# 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

[root@docker-ce ~]# dnf list docker-ce
Docker CE Stable - x86_64 1.7 kB/s | 3.8 kB 00:02
Available Packages
docker-ce.x86_64       3:19.03.13-3.el8            docker-ce-stable
[root@docker-ce ~]#

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

[root@docker-ce ~]# dnf install docker-ce --nobest -y

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

[root@docker-ce ~]# systemctl start docker
[root@docker-ce ~]# systemctl enable docker

Run the following command to verify installed docker version

[root@docker-ce ~]# docker --version
Docker version 19.03.13, build 4484c46d9d
[root@docker-ce ~]#

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,

[root@docker-ce ~]# 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,

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

Note: Replace “1.27.4” 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

[root@docker-ce ~]# chmod +x /usr/local/bin/docker-compose

Verify the docker compose version by running the following command.

[root@docker-ce ~]# docker-compose --version
docker-compose version 1.27.4, build 40524192
[root@docker-ce ~]#

Note : In case Docker Compose version command does not work, then run below to create soft link

[root@docker-ce ~]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

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 Use docker-compose to launch containers

Share Now!

25 thoughts on “How to Install Docker CE on CentOS 8 / RHEL 8”

  1. 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)

    Reply
  2. Hi Gunnar,

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

    # dnf install docker-ce –nobest -y

    Reply
  3. 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

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

    Reply
  5. 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/’

    Reply
  6. When trying to run `sudo docker run hello-world` the system returns:
    docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused “process_linux.go:449: container init caused \”write /proc/self/attr/keycreate: permission denied\””: unknown.
    ERRO[0000] error waiting for container: context canceled
    What went wrong here?

    Reply
  7. After installing Docker compose if it shows bash: docker-compose: command not found…
    You need to create a symbolic link /usr/bin or any other directory in your path.
    Try this:
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

    And then it works

    Reply
  8. @Pradeep Kumar containerd update from external repos is blocked by CentOS8. Workaround for now seems to be to install the CentOS7 version. If you don’t install it, you get the error you mentioned every time you try dnf update. –nobest is the enemy here.

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

    Reply
  9. I am getting below error for RHEL 8.2:
    Docker version 19.03.9, build 9d988398e7
    [root@control ~]# docker version
    Client: Docker Engine – Community
    Version: 19.03.9
    API version: 1.40
    Go version: go1.13.10
    Git commit: 9d988398e7
    Built: Fri May 15 00:25:27 2020
    OS/Arch: linux/amd64
    Experimental: false
    Error response from daemon: client version 1.40 is too new. Maximum supported API version is 1.39
    [root@control ~]#

    Reply
  10. @n jaywan

    upgrade to latest

    curl -L “https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    docker-compose –version

    Reply
  11. Hi Pradeep,

    I found you blog very useful, I was setting up docker on my RED HAT Enterprise edition and this blog simplified installation process.

    Thanks for posting it.

    Regards,
    Farooq

    Reply
  12. If you disable CentOS’ container-tools module you can install the latest Docker CE using docker-ce.repo, that is no more –nobest necessary:

    dnf module disable container-tools
    dnf install docker-ce docker-ce-selinux

    Reply
  13. you have to add on last step to be able to check the command “docker-compose –version” :

    ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

    Reply
  14. Hi there,
    Thanks for the great post! Is this solutions still valid? because I keep getting error running the first command. Please advice

    [osboxes@osboxes tmp]$ sudo dnf update -y ; reboot
    created by dnf config-manager from ‘https://download.docker.com/li’ 926 B/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.24)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    Failed to set wall message, ignoring: Interactive authentication required.
    Failed to reboot system via logind: Interactive authentication required.
    Failed to open initctl fifo: Permission denied
    Failed to talk to init daemon.
    [osboxes@osboxes tmp]$

    [osboxes@osboxes ~]$ sudo dnf update -y
    [sudo] password for osboxes:
    created by dnf config-manager from ‘https://download.docker.com/li’ 1.3 kB/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.58)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    [osboxes@osboxes ~]$ sudo dnf config-manager –add-repo=’https://download.docker.com/linux/centos/docker-ce.repo’
    Adding repo from: ‘https://download.docker.com/linux/centos/docker-ce.repo’
    [osboxes@osboxes ~]$ sudo dnf list docker-ce
    Docker CE Stable – x86_64 36 kB/s | 3.5 kB 00:00
    created by dnf config-manager from ‘https://download.docker.com/li’ 1.2 kB/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.79)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

    Reply
    • Hello Ibrahim,

      Above steps are still valid for CentOS 8 & RHEL 8. I have tested on CentOS 8 system, it is working as expected. I would suggest first remove the docker repository that you have configured and also remove podman and docker ( older version) in case it is installed.

      Update the system and then try these steps.

      Reply
    • use above in article to create repo and use below cmd to install
      #dnf install docker-* -y –nobest –allowerasing

      Reply

Leave a Comment