Update the apt package index and install packages to allow apt to use repository over HTTPS:
apt-get update
apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
When execute apt-get upate, it’s occurs an error:
Get:12 https://download.docker.com jessie/stable Translation-en [391 B]
Ign https://download.docker.com jessie/stable Translation-en
Fetched 44.8 kB in 3s (14.7 kB/s)
Reading package lists... Done
W: GPG error: https://download.docker.com jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
Execute the following scripts can easily fix this error:
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
But you may also encounter other errors during the installation that requires more follow-up. So the better solution is update debian jessie 8 to stretch 9, then to install docker again.
reference: https://stackoverflow.com/questions/60137344/docker-how-to-solve-the-public-key-error-in-ubuntu-while-installing-docker