First check whether docker is installed on your raspberry pi or not. Verify the docker installation by running the command below.
docker run -rm hello world
If the verification fails the docker needs to be installed on the raspberry pi.There are scripts available to support the installation of docker here at get.docker.comUse the command below to install using the scripts.curl -fsSL https://get.docker.com -o get-docker.shsudo sh get-docker.sh
The output would look something like the following:# Executing docker install script, commit: 26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c+ sh -c apt-get update -qq >/dev/null+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | apt-key add -qq - >/dev/nullWarning: apt-key output should not be parsed (stdout is not a terminal)+ sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbian stretch stable" > /etc/apt/sources.list.d/docker.list+ sh -c apt-get update -qq >/dev/null+ [ -n ]+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null+ sh -c docker versionClient: Docker Engine - CommunityVersion: 19.03.12API version: 1.40Go version: go1.13.10Git commit: 48a6621Built: Mon Jun 22 15:53:00 2020OS/Arch: linux/armExperimental: falseServer: Docker Engine - CommunityEngine:Version: 19.03.12API version: 1.40 (minimum version 1.12)Go version: go1.13.10Git commit: 48a6621Built: Mon Jun 22 15:47:00 2020OS/Arch: linux/armExperimental: falsecontainerd:Version: 1.2.13GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429runc:Version: 1.0.0-rc10GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version: 0.18.0GitCommit: fec3683If you would like to use Docker as a non-root user, you should now consideradding your user to the "docker" group with something like:sudo usermod -aG docker your-userRemember that you will have to log out and back in for this to take effect!WARNING: Adding a user to the "docker" group will grant the ability to runcontainers which can be used to obtain root privileges on thedocker host.Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surfacefor more information.Add your user to the docker group so that docker can be run without the super user permission.sudo usermod -aG docker pi
Now run the verification script and your docker should run.