本身是一個非常簡單的問題,這里簡單做個記錄,容器里面一般會有安裝一些軟件調試的需求,換個源之后會出現導入gpg的錯誤。
這里從改源開始
root@machine-learn:/etc/apt# echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > sources.list
root@machine-learn:/etc/apt# apt update
Get:1 http://mirrors.aliyun.com bionic InRelease [242 kB]
Ign http://mirrors.aliyun.com bionic InRelease
Get:2 http://mirrors.aliyun.com bionic/main amd64 Packages [1344 kB]
Get:3 http://mirrors.aliyun.com bionic/restricted amd64 Packages [13.5 kB]
Get:4 http://mirrors.aliyun.com bionic/universe amd64 Packages [11.3 MB]
Get:5 http://mirrors.aliyun.com bionic/multiverse amd64 Packages [186 kB]
Fetched 13.1 MB in 9s (1446 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
118 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: GPG error: http://mirrors.aliyun.com bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
# 報了個錯誤。開始導入key,key的這個值取決於上面的提示
root@machine-learn:/etc/apt# gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key C0B21F32 from hkp server keyserver.ubuntu.com
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key C0B21F32: public key "Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
root@machine-learn: /etc/apt# gpg --export --armor 3B4FE6ACC0B21F32 |apt-key add -
OK
# 接下來繼續執行apt update,隨后就可以下載安裝工具了
root@machine-learn:/etc/apt# apt update