繁体   English   中英

当Docker指向群体时无法从Docker注册表中提取图像

[英]Can't pull image from docker registry when docker is pointing to a swarm

我在google container registrydockerhub上遇到问题,其中dockerhub docker pull返回以下错误。

gcr

错误:状态403尝试提取存储库PROJECT_ID / IMAGE_NAME:“无法访问存储库:PROJECT_ID / IMAGE_NAME;请验证该存储库是否存在,并且您有权访问它(未提供有效的凭证)。”

dockerhub

使用默认标签:最新的test-node0:提取k8tems / hello-world:最新...:错误:未找到图像k8tems / hello-world错误:未找到图像k8tems / hello-world

这仅在Docker指向群体时发生。

重现步骤:

DOCKER_REGISTRY=asia.gcr.io/$PROJECT_ID
KEY_STORE=test-keystore
NODE_BASE=test-node

echo pushing hello-world image to gcr
docker pull hello-world
docker tag hello-world $DOCKER_REGISTRY/hello-world
docker push $DOCKER_REGISTRY/hello-world

echo setting up key store
docker-machine create \
    -d digitalocean \
    "$KEY_STORE"

docker $(docker-machine config "$KEY_STORE") run -d \
    -p "8500:8500" \
    -h "consul" \
    progrium/consul -server -bootstrap

eval $(docker-machine env "$KEY_STORE")

docker-machine create \
        -d digitalocean \
        --swarm \
        --swarm-master \
        --swarm-discovery="consul://$(docker-machine ip "$KEY_STORE"):8500" \
        --engine-opt="cluster-store=consul://$(docker-machine ip "$KEY_STORE"):8500" \
        --engine-opt="cluster-advertise=eth0:2376" \
        "$NODE_BASE"0

echo this fails
eval $(docker-machine env -swarm "$NODE_BASE"0)
docker pull $DOCKER_REGISTRY/hello-world

echo this succeeds
eval $(docker-machine env "$NODE_BASE"0)
docker pull $DOCKER_REGISTRY/hello-world

除了上面的代码片段,我还尝试将远程docker版本强制为1.10.3然后将其强制为1.1.3但错误仍然存​​在。

ubuntu:~$ docker-machine ls | grep test
test-keystore                -        digitalocean   Running   tcp://:2376                                       v1.10.3   
test-node0                   *        digitalocean   Running   tcp://:2376    test-node0 (master)                v1.10.3   
ubuntu:~$ docker exec swarm-agent-master /swarm -v
swarm version 1.1.3 (7e9c6bd)
ubuntu:~$ docker -v
Docker version 1.10.2, build c3959b1

我可以使用-swarm标志做些什么使我工作,还是必须对每个节点运行pull命令?

尝试JSON密钥文件! 当您使用集群或kubernetes之类的集群时,它是一个长期的凭证,比访问令牌更加一致。

示例命令:docker login -e 1234@5678.com -u _json_key -p“ $(cat keyfile.json)” https://gcr.io

这是具有更多详细信息的页面: https : //cloud.google.com/container-registry/docs/advanced-authentication#using_a_json_key_file

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM