Ubuntu 18.04 添加 gpg 密钥失败,出现 gpg-agent 未找到错误

Ubuntu 18.04 add gpg key failed with gpg-agent not found error

尝试将我们的基础映像迁移到稳定版 Ubuntu 18.04,当我们尝试添加我们的 gpg 密钥时,出现此错误:

root@77ff14f29cab:/# apt-key add apt-key.gpg 
gpg: failed to start agent '/usr/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: failed to start agent '/usr/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory

您缺少 gpg-agent 包,很可能是:

gpg-agent/testing,unstable,now 2.2.5-1 amd64 [installed,automatic]
  GNU privacy guard - cryptographic agent

您应该 运行 的命令是 apt install gpg-agent