无法在我的 ubuntu 上安装 docker,因为 apt-get update 中出现“NO_PUBKEY 7EA0A9C3F273FCD8”错误

Sae*_*ati 6 updates package-management apt dpkg

我正在尝试在 Ubuntu 20.04 LTS 上安装 Docker。我正在使用官方文档。我以前做过,没有问题。

这是运行后的错误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.
Run Code Online (Sandbox Code Playgroud)

我看到如何修复 GPG 错误“NO_PUBKEY”?但我无法解决问题。

mat*_*igo 7

您可能需要仔细检查 Docker 文档中的第二步是否已应用于您的系统:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Run Code Online (Sandbox Code Playgroud)

如果没有这个,您将无法连接到存储库。我刚刚在全新的 Ubuntu 安装上测试了安装步骤,一切正常,没有任何问题。希望这就是您需要做的全部

  • 这似乎不起作用。gpg 文件在那里,它具有适当的权限,甚至在“/etc/apt/keyrings”中尝试过。`sudo apt update` 仍然错误提示没有公钥。 (4认同)

小智 4

对我来说,我需要更改权限两次:

sudo chmod 755 /etc/apt/keyrings
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Run Code Online (Sandbox Code Playgroud)

我的默认 umask 甚至阻止 apt 读取文件夹...希望这对某人有帮助。