How to install Docker in CentOS 9/8/7

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to install Docker in CentOS 9(stream), CentOS 8 (stream) and CentOS 7.

To install Docker in CentOS, you can do so by using the official repository.

Whether you are running CentOS 7, 8 or 9, Docker supports all the three CentOS versions, so if your server is running any of the supported version of CentOS, then you will be able to run Docker on it.

With docker you can self host, or run different kind of apps in your server, without having to worry about apps conflicting.

Installing Docker in CentOS 9/8/7

In this tutorial, we'll be installing Docker in CentOS 9/8/7 via the official rpm Docker repository.

Before starting, ensure that your server doesn't contain an old version of Docker. If it does, then you need to make sure to remove it before installing Docker.

To remove Docker completely, simply run the command below.

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \

Step 1 - Install Prerequisites

You need to install the yum-utils package, in order to be able to add the Docker repository in the next step.

yum-utils contains the utility that we'll be using to add Docker rpm repository in our server.

To install yum-utils is very easy, and you can do so by running the command below.

sudo yum install yum-utils

Step 2 - Setup Docker repository

Since we'll be installing Docker via the rpm repository, then we need to manually add Docker repository in our machine.

To setup Docker repository, you can do so by using the yum-config-manager utility.

To do so, simply run the command below.

sudo yum-config-manager --add-repo

Step 3 - Install Docker

Now you can proceed to install Docker in your CentOS 9/8/7 server.

sudo yum install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin

Step 4 - Start Docker

You need to manually start Docker process after installing Docker, as it won't be running automatically.

You can check Docker status via the systemctl status command.

sudo systemctl staus docker

To start docker, simply run the following command.

sudo systemctl start docker

Step 5 - Verify Docker Installation

Docker process should be running now, so you can proceed to verify that Docker was installed correctly.

For example, to check if Docker runs, simply check Docker version via the --version command.

docker --version

As you can see, we are running Docker version 24.0.7

How to Download an Docker image from Docker Hub

If you are new to Docker, and don't know what apps you can run with Docker, then all you have to do is browse through Docker Hub, as Docker Hub contains over 100K images that you can install in your server.

1) Go to -

2) Look for the image you want to install.

For example, in this tutorial we are going to install the ubuntu image from the Hub repository.

You will be taken to the Ubuntu page

3) Install Docker image

To install an image in docker is quite simple, and you can do so by using the syntax as below

docker pull image

So since we are installing ubuntu we can install ubuntu via the command below

docker pull ubuntu

4) Run Docker image

Once ubuntu docker image has been downloaded, you can proceed to launch it.

To do so, simply issue the following command.

docker run -it ubuntu

We are using the -i and -t commands to run Ubuntu container in interactive and tty mode, as running the image, in this case the ubuntu image without these commands then we wouldn't be able to run commands in the Ubuntu container.

6) Use Docker container

Now that we are logged in to our Ubuntu container, we can use Ubuntu.

For example, since we are running the latest Ubuntu image, then we can easily verify by checking the output of /etc/os-release

cat /etc/os-release

As you can see, we are running Ubuntu 22.04 "Jammy Jellyfish" in our docker container.

To exit from docker container, you can use the exit command.


In this tutorial, you learned how to install Docker in CentOS 9(stream) in CentOS 8 (stream) and in CentOS 7.