Install Docker on CentOS 8 / RHEL 8
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. In this article, I’m going to share how to install Docker on CentOS 8 / RHEL 8.
Table of Contents
- Uninstall old Versions
- Set Up Repository
- Install Docker Engine (Community)
- Start Docker & Test
- Uninstall Docker
Step 1 : Uninstall old Versions
If the docker is installed, uninstall them, along with associated dependencies using this command:
sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
Step 2 : Set Up Repository
Before going to install Docker Engine, we need to set up the Docker repository.
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
Let’s set up the stable repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 3 : Install Docker Engine (Community)
Now Install the latest version of Docker Engine using this command:
sudo dnf install docker-ce --nobest
Installation completed. To install a specific version of Docker Engine – Community, you can see all available versions:
sudo dnf list docker-ce --showduplicates | sort -r
You’ll see the list like:
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
Now you can install your desired version using this command:
sudo dnf install docker-ce-<VERSION_STRING> --nobest
Step 4 : Start Docker & Test
Let’s start Docker:
sudo systemctl start docker
Enable Docker:
sudo systemctl enable docker
Check Docker status:
sudo systemctl status docker
Verify that Docker Engine – Community is installed correctly by running the hello-world
image:
sudo docker run hello-world
Step 5 : Uninstall Docker
Run this command to uninstall docker:
sudo dnf remove docker-ce
To delete all images, containers, and volumes, run this command:
sudo rm -rf /var/lib/docker
The article is over. Thanks for reading.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.