Installing Docker Engine on CentOS Stream 9

Docker is an open-source platform that allows you to develop, build, deploy, test, manage and run applications in containers. Containers are standardized units that include libraries, system tools, code, and runtime to run software or application.

Comparing Docker containers and Virtual Machines, here you can run multiple workloads (containers) on a single OS. Docker containers share the host OS kernel. Where, virtual machine does not provide the operating system kernel, it has its own. And the VMs are much more resource-intensive, instated of containers that are lightweight and don’t need separate operating systems. The differences between these two kind of infrastructures are much more.
One of the big advantages of Docker is ease of installation on most of the popular Linux distros and Windows.

In this article, I will show you how to install Docker Engine on CentOS Stream 9. Installation on other Linux distributions can be different. Feel free to look at official documentation

1. Installation

Below you can find confirmation regarding the operating system.

1. At first, let’s confirm that any old version of Docker isn’t installed in the system.
If you’re running a non-root user, remember to use sudo before these commands.

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

2. Install the yum-utils package and set up the repository. If prompted, accept the GPG key.

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

3. Install the latest version of Docker Engine.

yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4. Start Docker with a command:

systemctl start docker

5. Verify, that Docker Engine is working properly and pull hello-world image from the Docker Hub

docker run hello-world

6. To check (list) all existing/downloaded Docker images run a command:

docker images

7. To check version of the running Docker Engine type:

docker --version

8. To automatically start Docker and containerd on boot run enable docker.service and containerd.service:

systemctl enable docker.service
systemctl enable containerd.service

2. Set up non-root user to manage Docker

If you want to avoid typing sudo every time as a non-root user running Docker, you need to create docker group and add users to it.

1. Create the docker group.

groupadd docker

2. Add your user (in my case is user mateusz) to the docker group.

usermod -aG docker mateusz

3. Log out and log in to apply changes. Check if you can pull images without sudo.

docker run hello-world

Leave a Reply

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