Getting docker set up on CentOS 8 can be a little intimidating, but it doesn’t need to be. Follow this guide and you’ll be able to use it in no time.
Note: This guide assumes that you have a fresh install of CentOS 8 Stream. It may not work if you’ve made modifications.
First, add the Docker Stable repository to yum.
sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Now you can install docker!
# Either the latest version with this command sudo yum install docker-ce docker-ce-cli containerd.io --allowerasing # Or a specific version with this yum list docker-ce --showduplicates | sort -r # docker-ce.x86_64 3:20.10.6-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.5-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.4-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.3-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.2-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.1-3.el8 docker-ce-stable # docker-ce.x86_64 3:20.10.0-3.el8 docker-ce-stable # docker-ce.x86_64 3:19.03.15-3.el8 docker-ce-stable # docker-ce.x86_64 3:19.03.14-3.el8 docker-ce-stable # docker-ce.x86_64 3:19.03.13-3.el8 docker-ce-stable # sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io --allowerasing sudo yum install docker-ce-20.10.6 docker-ce-cli-20.10.6 containerd.io --allowerasing
Note: The –allowerasing flag for the yum commands above is critical, and you’ll encounter package conflict errors otherwise.
Next, just start and enable the docker service
sudo systemctl start docker sudo systemctl enable docker
You can test your docker installation with this
sudo docker run hello-world