[apt update docker 密鑰問題]
問題輸出
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密鑰問題,主要有兩個(gè)需要解決:
1. 修復(fù)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. 修復(fù)Ubuntu倉庫密鑰警告
# 將Ubuntu密鑰移動(dòng)到新的keyring目錄
sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/
3. 更新軟件包列表
sudo apt update
4. 如果還有問題,可以重新導(dǎo)入U(xiǎn)buntu密鑰
# 重新導(dǎo)入U(xiǎn)buntu官方密鑰
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
# 或者使用更現(xiàn)代的方式
sudo apt install ubuntu-keyring
執(zhí)行完這些步驟后,sudo apt update 應(yīng)該就不會再報(bào)錯(cuò)了。Docker倉庫的簽名問題會得到解決,Ubuntu倉庫的棄用警告也會消失。
以上內(nèi)容由AI生成,僅供參考和借鑒
Debian
啊,原來是Debian系統(tǒng)!之前的配置是針對Ubuntu的。對于Debian系統(tǒng)(特別是bookworm,即Debian 12),需要這樣修復(fù):
1. 刪除錯(cuò)誤的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等)。
關(guān)鍵區(qū)別是:
- Ubuntu使用:
https://download.docker.com/linux/ubuntu - Debian使用:
https://download.docker.com/linux/debian
現(xiàn)在應(yīng)該就能正常工作了!
以上內(nèi)容由AI生成,僅供參考和借鑒

浙公網(wǎng)安備 33010602011771號