Docker 登录成功,但没有拉或推被拒绝

问题描述 投票:0回答:2

当我尝试从 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
docker gitlab containers ubuntu-18.04
2个回答
0
投票

我无法确定明确的根本原因,但以下是有关该问题的一些事实,可能对其他人有帮助。

  • https://github.com/docker/docker-credential-helpers/issues/158:这是许多其他人面临的问题,像往常一样,许多人找到了许多适合他们的不同解决方案。
  • 这绝对是credsStore配置的问题。我能够在设置凭证助手之前进行身份验证,但之后就不行了。有些人能够卸载并且正常身份验证再次起作用。
  • 这似乎是与凭证助手未正确处理 gpg 密钥上的密码相关的问题。
  • 一种潜在的解决方案,
    export GPG_TTY=$(tty)
    ,可以通过允许密码提示到达终端来明确告诉 GPG 在哪里请求密码。
  • 另一个对我有用的潜在解决方案是将密码有效期设置为两年,然后手动提供密码,这可能会起作用,因为凭证助手不再需要询问密码(两年)。以下是该解决方法的步骤:
  1. 假设您已经安装了
    pass
    docker-credential-helpers
    设置并创建了 gpg 密钥...
  2. 将 gpg 密码超时设置为 2 年...
echo "default-cache-ttl 62208000" > ~/.gnupg/gpg-agent.conf
echo "max-cache-ttl 62208000" >> ~/.gnupg/gpg-agent.conf
  1. 重新启动 gpg 代理:
    gpg-connect-agent reloadagent /bye
  2. 执行
    pass show docker-credential-helpers
    ,这将为您提供类似于以下内容的凭证列表树:
docker-credential-helpers
└── Na4unc0Om0clab202nyjkdunWDK=
    └── itsme
  1. 根据以上输出执行
    pass show docker-credential-helpers/Na4unc0Om0clab202nyjkdunWDK=/itsme
    。这将要求您输入密码。

然后您应该能够完成 docker pull/push 命令。如果上述解决方案都不适合您,请随时阅读该主题以获取更多选项,并在此处分享有效的方法。


-1
投票

通过执行解决了问题

export GPG_TTY=(tty)

想法来自这篇文章https://github.com/docker/docker-credential-helpers/issues/158#issuecomment-516996013

我不明白它是如何工作的以及为什么。如果有人能解释一下,将不胜感激。

© www.soinside.com 2019 - 2024. All rights reserved.