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

I’m having an issue with google container registry and dockerhub where docker pull returns the following errors.

gcr

  • sonar-scanner-2.9.0.670 throws java.lang.ExceptionInInitializerError inside docker container
  • Jenkins docker plugin and linked slaves
  • How to fit docker in this architecture?
  • Docker run -d <private image> gives fatal. On other hosts it's ok?
  • Docker container doesn't start due to CMD and ENTRYPOINT
  • can't run docker image of jhipster webapp
  • Error: Status 403 trying to pull repository PROJECT_ID/IMAGE_NAME: “Unable to access the repository: PROJECT_ID/IMAGE_NAME; please verify that it exists and you have permission to access it (no valid credential was supplied).”

    dockerhub

    Using default tag: latest test-node0: Pulling
    k8tems/hello-world:latest… : Error: image k8tems/hello-world not
    found Error: image k8tems/hello-world not found

    This only happens when docker is pointing to a swarm.

    Steps to reproduce:

    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
    

    Along with the above snippet, I’ve also tried forcing the remote docker version to 1.10.3 and swarm to 1.1.3 but the error still persists.

    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
    

    Is there anything I can do to make this work with the -swarm flag or do I have to run the pull command for each node?

  • brief overview of current docker workflow with nginx
  • How to add module to Wildfly using CLI
  • Android ABI linked to wrong target
  • ebean-orm.xml not reloading after change
  • How to use docker remote api to create container?
  • Linked container IP not in hosts
  • One Solution collect form web for “Can't pull image from docker registry when docker is pointing to a swarm”

    Try JSON key file! It is a long-lived credential and much more consistent than access token when you are using clusters like swarm or kubernetes.

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

    Here is the page with more details:
    https://cloud.google.com/container-registry/docs/advanced-authentication#using_a_json_key_file

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.