Friday 23 July 2021

Docker installation on CentOS 8

 CentOS 8 uses the YUM package manager version v4.0.4. This version now uses DNF (Dandified YUM).

1) Use DNF to add and enable the official Docker CE repository. Type the following command in your terminal window:

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

2) To list all the available docker-ce packages, type:

dnf list docker-ce --showduplicates | sort -r
3) Install docker now
sudo dnf install docker-ce -y
4) Enable docker service to be start during system boot up
sudo systemctl enable docker

5) Start docker service
sudo systemctl start docker

6) Add current user to Docker User Group - We may need to restart session again to run docker cli commands with current user
sudo usermod -aG docker $USER
7) We need to disable firewalld for DNS resolution inside Docker containers to work
sudo systemctl disable firewalld
8) Test Docker setup.
docker run hello-world
After running above command you should be able to see below output.
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/