我正在尝试在 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.
我看见如何修复 GPG 错误“NO_PUBKEY”?但我无法解决这个问题。
答案1
您可能需要仔细检查 Docker 文档中的第二步是否已应用于您的系统:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
如果没有这个,您将无法连接到 repo。我刚刚在全新安装的 Ubuntu 上测试了安装步骤,一切顺利。希望这就是您需要做的全部
答案2
对我来说,我需要更改两次权限:
sudo chmod 755 /etc/apt/keyrings
sudo chmod a+r /etc/apt/keyrings/docker.gpg
我的默认 umask 甚至阻止 apt 读取该文件夹...希望这对某些人有帮助。
答案3
只需使用
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
没有解决我的问题。
我需要进一步:
sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg
然后sudo apt-get update
运行良好。
答案4
如果解决方案不起作用,则需要执行其他步骤。确保源列表中的 docker 条目具有下载密钥的位置:
deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stable