for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL <https://download.docker.com/linux/debian/gpg> -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \\
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <https://download.docker.com/linux/debian> \\
$(. /etc/os-release && echo "bookworm") stable" | \\
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
You might have to update the link on sudo curl -fsSL [<https://download.docker.com/linux/debian/gpg>](<https://download.docker.com/linux/debian/gpg>) -o /etc/apt/keyrings/docker.asc
based on what Linux distro you are using. For me, I was using a Debian distro so I had to update it from this link https://download.docker.com/linux/. Check if your distro is present or not.
After that you have to change the version name $(. /etc/os-release && echo "bookworm") stable" |
based on your distro’s version name. You have to go to dists
folder of your L
inux distro to find what version is
available for you and choose the version name based on your PC. For me it was debian and the version was bookworm.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
hello-world
image and run.sudo docker run hello-world
If all the process goes right then it will show something like this. Now installation is complete.