【问题标题】:Why am I unable to run a docker container in my cloud devshell?为什么我无法在我的云 devshell 中运行 docker 容器?
【发布时间】:2018-06-25 02:22:37
【问题描述】:

我正在关注https://cloud.google.com/container-builder/docs/quickstart-docker 上的教程。我已构建映像并将其推送到 Google 的 gcr.io 注册表。

$ gcloud auth configure-docker
gcloud credential helpers already registered correctly.

$ docker run --init gcr.io/foo-bar-111111/quickstart-image
Unable to find image 'gcr.io/foo-bar-111111/quickstart-image:latest' locally
docker: Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication.
See 'docker run --help'.

$ docker-credential-gcr configure-docker
/home/wonderwoman/.docker/config.json configured to use this credential helper for GCR registries

$ docker run --init gcr.io/foo-bar-111111/quickstart-image
Unable to find image 'gcr.io/foo-bar-111111/quickstart-image:latest' locally
docker: Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication.
See 'docker run --help'.

$ docker pull gcr.io/foo-bar-111111/quickstart-image:latest
Please login prior to pull:
error getting credentials - err: exit status 1, out: `docker-credential-gcr/helper: could not retrieve GCR's access token: credentials not found in native keychain`

我错过了什么?

【问题讨论】:

    标签: docker google-cloud-platform


    【解决方案1】:

    您将gcloud 用作Docker credential helper

    gcloud auth configure-docker
    

    因此,您必须使用 docker 注册表中的 gcloud dockerdocker pull 映像。 gcloud docker 仍然在底层使用 Docker,但在移交给 Docker 之前将使用 Container Registry 凭据注入 Docker 客户端。

    使用您的示例:

    gcloud docker pull gcr.io/foo-bar-111111/quickstart-image:latest
    

    您可能还必须使用sudo,来制作完整的命令:

    sudo gcloud docker pull gcr.io/foo-bar-111111/quickstart-image:latest
    

    【讨论】:

    • 文档有一个小警告,上面写着 gcloud docker 仅推荐用于 1.13 之前的 Docker 客户端版本。这是让我感到困惑的事情。我会尝试你的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-22
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 2021-11-14
    相关资源
    最近更新 更多