1. Update your existing list of packages:
sudo apt update
2. Install a few prerequisite packages which let apt
use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. Add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4. Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
5. Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
apt-cache policy docker-ce
You will see the output like this:
Notice that docker-ce
is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04
6. Install Docker:
sudo apt install docker-ce
7. Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
sudo systemctl status docker
Source: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04