
我正在嘗試在 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
如果沒有這個,您將無法連接到儲存庫。我剛剛在全新的 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