Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: How to solve the public key error in ubuntu while installing docker

Tags:

docker

ubuntu

I am getting the below error message when running the below command for installing docker and kubernetes in Ubuntu server.

root@master:/home/ubuntu# add-apt-repository \
>   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>   $(lsb_release -cs) \
>   stable"
Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu bionic-security InRelease
**Err:2 https://download.docker.com/linux/ubuntu bionic InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8**
Reading package lists... Done
W: GPG error: https://download.docker.com/linux/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8
**E: The repository 'https://download.docker.com/linux/ubuntu bionic InRelease' is not signed.**
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@master:/home/ubuntu#

I have also ran the below command but no luck

root@master:/# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
Executing: /tmp/apt-key-gpghome.rDOuMCVLF2/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
gpg: keyserver receive failed: No keyserver available
like image 285
Chandra Avatar asked Feb 09 '20 13:02

Chandra


People also ask

How do I download Docker on Ubuntu?

Go to https://download.docker.com/linux/ubuntu/dists/ , choose your Ubuntu version, then browse to pool/stable/ , choose amd64 , armhf , arm64 , or s390x , and download the .deb file for the Docker Engine version you want to install.

Does Ubuntu 20.04 have Docker?

In this tutorial, you'll install and use Docker Community Edition (CE) on Ubuntu 20.04. You'll install Docker itself, work with containers and images, and push an image to a Docker Repository.


Video Answer


2 Answers

I had this exact problem. I believe it was caused by my default umask, which caused some of the Docker files to be installed with incorrect permissions. I was able to fix it by correcting the file permissions the docker key file:

sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg
like image 61
qarl Avatar answered Oct 17 '22 12:10

qarl


EDIT: This apparently does not work any more.

Run this to add the correct key:

# Does not work any more
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Source: https://docs.docker.com/install/linux/docker-ce/ubuntu/

like image 42
tuomassalo Avatar answered Oct 17 '22 11:10

tuomassalo