Installation guide for Docker and Docker Compose on Ubuntu 20.04 Machine.
-
Uninstall the previous versions of the Docker present in the machine:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
-
Update the apt package and install the all certificates to allow the repo to use over HTTPS:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
-
Add Docker's official GPG Key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
-
Use the following command to set up the repository:
echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Update the apt package index:
sudo apt-get update
-
Install the Docker Engine, containerd, and Docker Compose:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
-
Check the version of the Docker and Docker Compose:
docker --version
docker compose version