Install Docker Engine on Ubuntu

Installing Docker on Ubuntu 20.04

  1. Update the apt package index:
sudo apt update
  1. Uninstall old version(s):
sudo apt remove docker docker-engine docker.io containerd runc
  1. Set up the Docker apt repository:
sudo apt install ca-certificates curl gnupg lsb-release -y
  1. Add Docker's GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. Add the Docker repository:
 echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Update the apt package index:
sudo apt update
  1. Install the Docker engine:
sudo apt install docker-ce docker-ce-cli containerd.io -y
  1. Add the docker group:
sudo groupadd docker
  1. Add your username to the docker group:
sudo usermod -aG docker $USER
  1. After logging out, then back in, verify you can run docker commands without sudo:
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

References

Docker Docs - Install Docker Engine on Ubuntu https://docs.docker.com/engine/install/ubuntu/