The following assumes that you already have SSH access to a running server. In case you've just unboxed your RaspberryPi and are now wondering how to install a 64bit OS on it, have a look at the RaspberryPi 4 Setup.
Setup the Repository
First we need to setup access to the Docker package repository.
$ sudo apt-get install -y \
Add Docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify the GPG fingerprint
Setup access to the stable repository. Note, here we're doing this for arm64. This command will be different when you want to do this on another architecture.
$ sudo add-apt-repository \
"deb [arch=arm64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
Install the latest version of Docker Engine
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Add the current user to the docker group
$ sudo usermod -aG docker $USER
Lets now do a quick restart and see whether the docker engine is running
$ sudo shutdown -r now
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES