【问题标题】:Cannot access Google Container Registry from Google Compute Engine无法从 Google Compute Engine 访问 Google Container Registry
【发布时间】:2017-06-03 13:30:59
【问题描述】:

我正在尝试将 Docker 映像从 Google Container Registry 获取到 Google Compute Engine 实例上。 (我需要的图片已经成功上传到GCR。)

  1. 我使用gcloud auth login 登录,然后尝试gcloud docker pull -- us.gcr.io/app-999/app,结果为ERROR: (gcloud.docker) Docker is not installed.

  2. 我尝试使用oauth 进行身份验证并通过正常的 docker 调用进行拉取。当我查看.docker/config.json 的文件时,我看到了我的凭据。这样做,看起来它会起作用,但最终是这样结束的:

    mbname@instance-1 ~ $ docker pull -- us.gcr.io/app-999/app Using default tag: latest latest: Pulling from app-999/app b7f33cc0b48e: Pulling fs layer 43a564ae36a3: Pulling fs layer b294f0e7874b: Pulling fs layer eb34a236f836: Waiting error pulling image configuration: unauthorized: authentication required

这看起来像是进度,因为至少它尝试下载了一些东西。

我也在本地机器上尝试了这两种方法,两种方法都成功了。

我错过了什么吗?

感谢您的帮助。

附:我还尝试从另一个注册表加载容器( Docker Hub),效果很好,但我需要多个容器并且希望降低开支。

【问题讨论】:

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


    【解决方案1】:

    docker 应包含在最新版本的gcloud 中。您可以通过运行gcloud components update 更新到最新版本的gcloud

    【讨论】:

    • 运行mbname@instance-1 ~ $ gcloud components update 产生You cannot perform this action because this Cloud SDK installation is managed by an external package manager. If you would like to get the latest version, please see our main download page at: https://cloud.google.com/sdk/ ERROR: (gcloud.components.update) The component manager is disabled for this installation
    【解决方案2】:

    在联系 Google 支持后,他们告诉我 CoreOS gcloud 别名中存在错误。通过覆盖 shell 中的别名来修复此错误,如下所示:

    alias gcloud='(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net=host -v $HOME/.config:/.config -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker google/cloud-sdk gcloud'
    

    我试过了,现在可以了。

    【讨论】:

    • 您在何时何地运行此程序?启动时在您的计算引擎上?
    • 注意配置路径。对我来说是-v $HOME/.config:/root/.config。甚至更好:-v $HOME/.config/gcloud:/root/.config/gcloud
    猜你喜欢
    • 1970-01-01
    • 2021-12-22
    • 2018-02-14
    • 1970-01-01
    • 2017-04-26
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    相关资源
    最近更新 更多