【问题标题】:Can't authenticate to Google Container Registry using JSON key file from within GCR无法使用 GCR 中的 JSON 密钥文件向 Google Container Registry 进行身份验证
【发布时间】:2020-01-10 23:37:29
【问题描述】:

我 [相信我] 在我的本地系统和构建系统之间设置了类似的工具和配置。

我可以在本地成功运行它:

$ cat key.json | docker login -u _json_key --password-stdin https://us.gcr.io
WARNING! Your password will be stored unencrypted in /home/local/MAGICLEAP/doprea/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

..但是相同的命令在 GCE 中运行的作业中失败:

cat key.json | docker login -u _json_key --password-stdin https://us.gcr.io
error getting credentials - err: exit status 1, out: `docker-credential-gcr/helper: could not retrieve GCR's access token: metadata: GCE metadata "instance/service-accounts/default/token?scopes=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform" not defined`

似乎真的想在实例元数据中找到令牌,而不仅仅是使用我提供的文件。

我可以参考一些建议。

【问题讨论】:

    标签: docker google-compute-engine google-container-registry


    【解决方案1】:

    您的“.docker/config.json”文件可能有问题,您可以比较本地系统和构建系统之间的“config.json”。

    在您的构建系统中运行以下命令来验证 docker 的状态和配置文件,请确保在故障排除之前安装了“docker-credential-gcr”。

    $ docker -v

    $ docker-credential-gcr 配置-docker

    $ cat ~/.docker/config.json

    $ docker login -u oauth2accesstoken -p "$(gcloud auth print-access-token)" https://us.gcr.io

    我推荐这些主题 “Pushing and pulling images”“Authentication methods” 进行故障排除。

    【讨论】:

    • 是的。我已将本地配置复制到远程系统,但它仍然无法正常工作。是的。我浏览过这些页面。
    • 这在我的测试环境下工作,我编辑了第四个命令用于测试和故障排除,还建议您更新并重新初始化Google Cloud SDK,cloud.google.com/sdk/docs/#install_the_latest_cloud_sdk_version您可能需要系统管理员权限“ sudo" 来运行命令。
    • 这专门绕过了我报告的问题。我们没有元数据中有我们的密钥。它在物理文件中。即使我们将它传入,我们也会收到关于在元数据中找不到它的错误。
    • 执行此命令“docker login -u _json_key --password-stdin us.gcr.io medium.com/infrastructure-adventures/…
    • 它和问题中的原始命令功能相同,所以结果是一样的。
    猜你喜欢
    • 1970-01-01
    • 2020-12-27
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2019-02-17
    • 1970-01-01
    相关资源
    最近更新 更多