问题输出
Get:26 http://mirrors.aliyun.com/ubuntu focal-backports/restricted amd64 DEP-11 Metadata [212 B]
Get:27 http://mirrors.aliyun.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB]
Get:28 http://mirrors.aliyun.com/ubuntu focal-backports/multiverse amd64 DEP-11 Metadata [212 B]
Reading package lists... Done
W: http://mirrors.aliyun.com/ubuntu/dists/focal/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
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.
W: http://mirrors.aliyun.com/ubuntu/dists/focal-security/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://mirrors.aliyun.com/ubuntu/dists/focal-updates/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://mirrors.aliyun.com/ubuntu/dists/focal-proposed/InRelease: Key is stored


这是GPG密钥问题,主要有两个需要解决:
1. 修复Docker仓库密钥问题
# 添加Docker官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 更新Docker仓库配置
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2. 修复Ubuntu仓库密钥警告
# 将Ubuntu密钥移动到新的keyring目录
sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/
3. 更新软件包列表
sudo apt update
4. 如果还有问题,可以重新导入Ubuntu密钥
# 重新导入Ubuntu官方密钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
# 或者使用更现代的方式
sudo apt install ubuntu-keyring
执行完这些步骤后,sudo apt update 应该就不会再报错了。Docker仓库的签名问题会得到解决,Ubuntu仓库的弃用警告也会消失。
以上内容由AI生成,仅供参考和借鉴
Debian
啊,原来是Debian系统!之前的配置是针对Ubuntu的。对于Debian系统(特别是bookworm,即Debian 12),需要这样修复:
1. 删除错误的Docker仓库配置
sudo rm /etc/apt/sources.list.d/docker.list
2. 为Debian添加正确的Docker仓库
# 添加Docker官方GPG密钥
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 添加Docker仓库(注意是debian,不是ubuntu)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
3. 更新软件包列表
sudo apt update
4. 如果还有问题,检查Debian版本
lsb_release -cs
# 或者
cat /etc/os-release | grep VERSION_CODENAME
确保使用正确的Debian版本代号(bookworm、bullseye、buster等)。
关键区别是:
- Ubuntu使用:https://download.docker.com/linux/ubuntu
- Debian使用:https://download.docker.com/linux/debian
 现在应该就能正常工作了!
以上内容由AI生成,仅供参考和借鉴