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

  • Docker swarm, Consul and Spring Boot
  • Docker - Downloaded war not found
  • Failed to execute git command in Docker container using fig/crane
  • Get mysql error when deploy laravel project with Docker
  • How to get the docker container logs using docker-java client library
  • How to load docker image from tar file
  • 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?

  • Only receiving MQTT messages in interactive mode within a docker container
  • Exposed port shows as filtered when using nmap
  • Docker with `/bin/bash -c` running mysql deamon
  • Can I use Docker like this …?
  • docker - can't connect to external postgres db
  • IntelliJ IDEA and docker plugin
  • 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.