6

I'm trying to install Docker on Ubuntu 20.04 LTS. I'm using the official docs. I have done it before without problems.

Here's the error after running sudo apt-get update:

Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://packages.microsoft.com/repos/code stable InRelease                                                       
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                             
Hit:4 http://ir.archive.ubuntu.com/ubuntu focal InRelease                   
Hit:5 http://ir.archive.ubuntu.com/ubuntu focal-updates InRelease              
Get:6 https://download.docker.com/linux/ubuntu focal InRelease [52.1 kB]       
Hit:7 http://ir.archive.ubuntu.com/ubuntu focal-backports InRelease                        
Err:6 https://download.docker.com/linux/ubuntu focal 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 focal 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 focal 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.

I saw How do I fix the GPG error "NO_PUBKEY"? but I couldn't solve the problem.

muru
  • 197,895
  • 55
  • 485
  • 740
Saeed Neamati
  • 793
  • 2
  • 7
  • 20

4 Answers4

7

You may want to double-check that the second step in Docker's documentation has been applied against your system:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Without this, you will not be able to connect to the repo. I've just tested the installation steps on a fresh Ubuntu installation and everything has worked without any problem. Hopefully this is all you need to do

matigo
  • 22,138
  • 7
  • 45
  • 75
  • 4
    This does not appear to work. The gpg file is there, it has proper perms, even tried in /etc/apt/keyrings. sudo apt update still errors out that there is no public key. – Douglas Gaskell Sep 20 '22 at 21:02
5

For me I needed to change permissions twice:

sudo chmod 755 /etc/apt/keyrings
sudo chmod a+r /etc/apt/keyrings/docker.gpg

My default umask was preventing apt from even reading in the folder... hope this helps someone.

ifiht
  • 166
4

Just using

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

didn't solve my problem.

I need further:

sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg

and then sudo apt-get update works well.

Inspired by https://stackoverflow.com/a/68764068/7701908.

one
  • 141
1

There is need for additional step if solution doesn't work. Make sure that the docker entry in sources list has the location of the downloaded key :

deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stable