Docker is an operating system virtualization tool that allows us to run applications as containers. In simplest terms, that means you are virtualizing only the application, and not creating an entire virtual machine as you would traditionally do in hypervisors like VMware, Hyper-V, or Nutanix.
Okay, that’s cool… How do we install Docker so we can start to test workloads on it? Well, let me show you how to install Docker on a virtual machine running CentOS 9 Stream.
**While I have not tested to confirm, this Docker installation method should be identical on CentOS 8 Stream, as well as for CentOS 7.x
Let us begin by shifting to Sudo mode by running this command first…
Then the first thing to do is remove PodMan as it conflicts with Docker.
dnf -y remove podman runc
The next step is to add the Docker repo.
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
Update SELinux in regards to the Docker repo.
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/docker-ce.repo
Enable the Docker repo and install Docker.
dnf --enablerepo=docker-ce-stable -y install docker-ce
With Docker installed, it is time to enable it.
systemctl start docker
systemctl enable docker
Let us view what we installed by running these two commands.
rpm -q docker-ce
Congratulations! You now have Docker installed on your machine.
You’ll probably want to install Docker Compose on your machine too so you can build and run a docker image. You can install it with this simple command.
dnf install docker-compose