apt-get update で「NO_PUBKEY 7EA0A9C3F273FCD8」エラーが発生したため、Ubuntu に docker をインストールできません

apt-get update で「NO_PUBKEY 7EA0A9C3F273FCD8」エラーが発生したため、Ubuntu に docker をインストールできません

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 のドキュメントの 2 番目の手順がシステムに適用されているかどうかを再確認することをお勧めします。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

これがないと、リポジトリに接続できません。Ubuntu の新規インストールでインストール手順をテストしたところ、すべて問題なく動作しました。これで必要な作業はすべて完了です。

答え2

私の場合は権限を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うまく動作します。

に触発されたhttps://stackoverflow.com/a/68764068/7701908

答え4

解決策が機能しない場合は、追加の手順が必要です。ソース リストの docker エントリにダウンロードしたキーの場所が含まれていることを確認します。

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

関連情報