Search code examples
dockergoogle-compute-enginegcloudgoogle-container-registry

Cannot access Google Container Registry from Google Compute Engine


I'm at my wits trying to get Docker images from Google Container Registry onto a Google Compute Engine instance. (The images I need have been successfully uploaded to GCR.)

  1. I've logged in using gcloud auth login and then tried gcloud docker pull -- us.gcr.io/app-999/app which results in ERROR: (gcloud.docker) Docker is not installed..

  2. I've tried to authenticate using oauth and pulling via a normal docker call. I see my credentials when I look at the file at .docker/config.json. Doing that, it looks like it's going to work, but ultimatly ends like this:

    mbname@instance-1 ~ $ docker pull -- us.gcr.io/app-999/app Using default tag: latest latest: Pulling from app-999/app b7f33cc0b48e: Pulling fs layer 43a564ae36a3: Pulling fs layer b294f0e7874b: Pulling fs layer eb34a236f836: Waiting error pulling image configuration: unauthorized: authentication required

which looks like progress, because at least it attempted to download something.

I've tried both of these things on my local machine as well and both methods were successful.

Am I missing something?

Thanks for your help.

P.S. I've also tried loading a container from another registry ( Docker Hub) and that worked fine, but I need more than one container and want to keep expenses down.


Solution

  • After contacting Google support they informed me that there is a bug in the CoreOS gcloud alias. This bug is fixed by overwriting the alias in the shell as follows:

    alias gcloud='(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net=host -v $HOME/.config:/.config -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker google/cloud-sdk gcloud'
    

    I've tried this and it works now.