Download the installer script from docker.com. https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script
curl -fsSL https://get.docker.com -o get-docker.sh
Then run it using root privileges.
sudo sh get-docker.sh
Add yourself to the docker group
Add yourself to the docker group when you get an error like this:
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json": dial unix /var/run/docker.sock: connect: permission denied
sudo usermod -aG docker $USER
