Install Docker on Ubuntu 21.04+

(This should also work for Debian-based distributions)

Install the docker package:

sudo apt update
sudo apt upgrade
sudo apt install docker.io

Start the docker process and enable the service:

sudo systemctl enable --now docker

Check that docker is now running:

sudo systemctl status docker

Output should look similar to this (specifically look for active (running)):

● docker.service - Docker Application Container Engine
     Loaded: loaded (docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-11-02 18:23:14 UTC; 24h ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 4001 (dockerd)
      Tasks: 12
     Memory: 42.3M
        CPU: 21.132s
     CGroup: /system.slice/docker.service
             └─4001 dockerd -H fd:// --containerd=containerd.sock

Create the docker group and add your user to it:

sudo groupadd docker
sudo usermod -aG docker $USER

(If you want to add a different user, replace $USER with username.)

See the docker version:

docker --version

Output:

Docker version 20.10.7, build 20.10.7-0ubuntu5

And there you have it! Keep calm and docker on!