更新docker时报GPG密钥不可用

Evek Golden Lv4

Docker repository’s GPG key is not available

环境

Ubuntu 22.04 LTS (WSL 2)

docker.list

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

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
(base) ➜  Documents sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Get:5 https://download.docker.com/linux/ubuntu jammy InRelease [48.8 kB]
Err:5 https://download.docker.com/linux/ubuntu jammy 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 jammy 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 jammy 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.

解决办法

原因:Docker仓库的GPG密钥在你的系统中不可用。

解决步骤:

  1. 下载Docker GPG密钥并将其添加到系统

    1
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  2. 将Docker仓库添加到源列表中,并使用已签名的密钥

    1
    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  3. 再次更新包列表

    1
    sudo apt update
  • Title: 更新docker时报GPG密钥不可用
  • Author: Evek Golden
  • Created at : 2024-06-16 22:46:00
  • Updated at : 2026-06-12 08:57:02
  • Link: https://blog.cocodemo.uno/posts/69dded34/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments