How to Install Docker on CentOS 8

I have been using Docker for some time. But mostly, I use the Docker installed on Ubuntu. Now I am going to install Docker on CentOS 8. It is very easy to get Docker up and running on CentOS. I run CentOS on my Proxmox server and connect from a Windows 10 machine.

In this article you will learn the following:

  • Install Docker on CentOS 8
  • Create a new container
  • Install Portainer – web GUI management for Docker

Install Docker on CentOS 8

Step 1. Add the repository

Docker is not available in CentOS 8 repository. So, we need to add the external repository. Open Terminal or connect to CentOS via SSH. And then paste the following line.

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Next, check or confirm with this command

dnf repolist -v

It will produce something like this

Step 2. Install Docker

Now we are ready to install Docker. Use this command to install Docker community edition.

dnf install --nobest docker-ce

When the installation finishes, we need to start and enable Docker service.

systemctl enable docker
systemctl start docker --now

Let’s check the Docker service status

systemctl status docker

At this point, we have successfully installed Docker on CentOS 8. Next, we will try to run a new container.

Step 3. Add User to Docker Group

By default, only root and sudo user that can run and manage Docker. If you want to add the normal user to Docker group, do the following

sudo usermod -aG docker $USER

Disable firewalld

In order to allow Docker containers to communicate with the network, we need to disable firewalld on CentOS.

systemctl disable firewalld

Now reboot CentOS for the change to take effect.

Create a New Container

Now we are going to try Docker. We will try to pull an image from the Docker repository.

docker pull hello-world

Now let’s run hello-world

docker run hello-world
install docker on centos 8

Install Portainer on CentOS 8

Portainer is a graphical Docker management. We can easily run the various applications, pull images, and manage Docker installation via a web browser. You can install Portainer with this simple command

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Now open the web browser and type the CentOS IP address with the following format

http://centos-ip-address:9000

For example:

http://192.168.100.56:9000
Portainer create a new user

Next, click Local since we are going to manage Docker installed in the localhost (CentOS 8).

install docker on centos 8

Done. Thanks for reading the article.

Be the first to comment

Leave a Reply

Your email address will not be published.


*