\`docker pull\` 从私有 gitlab 注册表返回 \`denied: access denied\`

新手上路,请多包涵

我有一个 Dockerfile 将被实施 FROM 一个私有注册表的镜像。 I build this file without any problem with Docker version 1.12.6, build 78d1802 and docker-compose version 1.8.0, build unknown , but in another machine which has Docker version 17.06.1-ce, build 874a737 and docker-compose version 1.16.1, build 6d1ac21 , the docker-compose build 返回:

 FROM my.private.gitlab.registry:port/image:tag
http://my.private.gitlab.registry:port/v2/docker/image/manifests/tag: denied: access forbidden

docker pull my.private.gitlab.registry:port/image:tag 返回相同。

请注意,我试图获取 my.private.registry:port/image:taghttp://my.private.registry:port/v2/docker/image/manifests/tag 已被捕获。

原文由 Zeinab Abbasimazar 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

如果这是一个经过身份验证的注册表,那么您需要在构建它的机器上运行 docker login <registryurl>

每个主机只需执行一次。然后该命令将身份验证缓存在文件中

$ cat ~/.docker/config.json
{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "......="
        }
    }
}

原文由 Tarun Lalwani 发布,翻译遵循 CC BY-SA 4.0 许可协议

登录并没有为我解决问题。这可能特定于 Mac,但以防万一这是 Git 问题

我对此的评论:

也遇到这个问题。

Dockerfile:

FROM <insert_private_registry>/test-image:latest

命令行界面

如果没有登录私有注册表,这两个命令都会失败(预期)

     $ docker-compose up
    Building app
    Step 1/2 : FROM <insert_private_registry>/test-image:latest
    ERROR: Service 'app' failed to build: Get https://<insert_private_registry>/v2/test-image/manifests/latest: denied: access forbidden

    $ docker pull <insert_private_registry>/test-image:latest
    Error response from daemon: Get https://<insert_private_registry>/test-image/manifests/latest: denied: access forbidden

登录后,一个 docker pull ... 工作,而 docker-compose up 无法提取图像:

     $ docker login <insert_private_registry>
    Username: <insert>
    Password: <insert>
    Login Succeeded

    $ docker-compose up
    Building app
    Step 1/2 : FROM <insert_private_registry>/test-image:latest
    ERROR: Service 'app' failed to build: Get https://<insert_private_registry>/v2/test-image/manifests/latest: denied: access forbidden

    $ docker pull <insert_private_registry>/test-image:latest
    latest: Pulling from <insert_private_image_path>/test-image
    ...
    Status: Downloaded newer image for <insert_private_registry>/test-image:latest

当前解决方案

我们当前的解决方法是在运行 docker-compose 容器之前显式拉取镜像:

     docker pull <insert_private_registry>/test-image:latest
    latest: Pulling from <insert_private_image_path>/test-image
    ...
    Status: Downloaded newer image for <insert_private_registry>/test-image:latest

    $ docker-compose up
    Building app
    Step 1/2 : FROM <insert_private_registry>/test-image:latest
    ...

原文由 Isaiah 发布,翻译遵循 CC BY-SA 4.0 许可协议