Installing Docker on Linux can be tricky. Follow the instructions step by step.
- Distribution: Ubuntu Focal 20.04 (LTS)
Check the Ubuntu release version
lsb_release -d
Update the apt package
- Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
Set up the Docker repositories
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] \ https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable"
Install Docker packages
sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io sudo apt-mark hold docker-ce
Confirm installation of Docker
sudo docker version
Use Docker as a non-root user
sudo usermod -aG docker <user-name> docker version
- You need to log out and log in again.
Run docker
docker run hello-world