当我尝试从 github.com 上的容器 Container Registry 拉取或推送映像时。
经过检查,我注意到
.docker/config.json
没有保存docker登录凭据
$ docker login registry.gitlab.com -u [username]
Password:
Login Succeeded
$ cat ~/.docker/config.json
{
"auths": {
"registry.gitlab.com": {}
},
"credsStore": "pass"
}
我也在使用 docker-credential-helpers。 我的Ubuntu版本
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
我无法确定明确的根本原因,但以下是有关该问题的一些事实,可能对其他人有帮助。
export GPG_TTY=$(tty)
,可以通过允许密码提示到达终端来明确告诉 GPG 在哪里请求密码。pass
、docker-credential-helpers
设置并创建了 gpg 密钥...echo "default-cache-ttl 62208000" > ~/.gnupg/gpg-agent.conf
echo "max-cache-ttl 62208000" >> ~/.gnupg/gpg-agent.conf
gpg-connect-agent reloadagent /bye
pass show docker-credential-helpers
,这将为您提供类似于以下内容的凭证列表树:docker-credential-helpers
└── Na4unc0Om0clab202nyjkdunWDK=
└── itsme
pass show docker-credential-helpers/Na4unc0Om0clab202nyjkdunWDK=/itsme
。这将要求您输入密码。然后您应该能够完成 docker pull/push 命令。如果上述解决方案都不适合您,请随时阅读该主题以获取更多选项,并在此处分享有效的方法。
通过执行解决了问题
export GPG_TTY=(tty)
想法来自这篇文章https://github.com/docker/docker-credential-helpers/issues/158#issuecomment-516996013
我不明白它是如何工作的以及为什么。如果有人能解释一下,将不胜感激。