How did I install Docker to Debian 9 (Stretch)?

I used the official manual as a base: docs.docker.com/engine/installation/linux/docker-ce/debian

Step 1

aptitude remove docker docker-engine docker.io
aptitude install apt-transport-https ca-certificates curl gnupg2 

Step 2

I use apt-get instead of aptitude to overcome the «policykit-1 : Depends: libpam-systemd but it is not installable» issue.

apt-get install software-properties-common

Step 3

curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Step 4 (optional)

add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
   $(lsb_release -cs) \
   stable"

This step adds the following lines to the /etc/apt/sources.list file:

deb [arch=amd64] https://download.docker.com/linux/debian stretch stable
deb-src [arch=amd64] https://download.docker.com/linux/debian stretch stable

So use it only if you do not have these lines yet.
See also: My /etc/apt/sources.list for Discourse in Debian 9 (Stretch).

Step 5

aptitude update && aptitude install docker-ce

Step 6 (verification)

docker run hello-world

See also: How did I install Docker to Debian 10 (Buster)?