<p>I have a GKE cluster running in GCE, I was able to build + tag an image derived from ubuntu:16.04:</p>

<pre><code>/ # docker images
REPOSITORY                          TAG                 IMAGE ID            
CREATED             SIZE
eu.gcr.io/my-project/ubuntu-gcloud   latest              a723e43228ae        7 minutes ago       347MB
ubuntu                              16.04               ebcd9d4fca80        7 days ago          118MB
</code></pre>

<p>First I try to log in to registry (as documented in GKE docs)  <code>
docker login -u oauth2accesstoken -p `curl -s "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" -H "Metadata-Flavor: Google"|awk -F\" "{ print \$4 }"` eu.gcr.io`
</code></p>

<p>And then the <code>docker push</code> command fails:</p>

<pre><code># docker push eu.gcr.io/my-project/ubuntu-gcloud
The push refers to a repository [eu.gcr.io/my-project/ubuntu-gcloud]
a3a6893ab23f: Preparing
6e390fa7d62c: Preparing
22b8fccbaf84: Preparing
085eeae7a10b: Preparing
b29983dd2306: Preparing
33f1a94ed7fc: Waiting
b27287a6dbce: Waiting
47c2386f248c: Waiting
2be95f0d8a0c: Waiting
2df9b8def18a: Waiting
denied: Unable to create the repository, please check that you have access to do so.
</code></pre>

<p>The token should be valid, in another instance I'm able to <code>gcloud whatever</code> with it; the service account has 'Editor' role on the project.</p>

<p>The weirdest part is when I do <code>docker login</code> with obviously invalid credentials</p>

<pre><code>misko@MacBook ~ $ docker login -u oauth2accesstoken -p somethingverystupidthatisreallynotmypasswordortoken123 eu.gcr.io
Login Succeeded
</code></pre>

<p>login always succeeds.</p>

<p>What shall I do to successfully <code>docker push</code> to gcr.io?</p>

<p>Try this:</p>

<pre><code>gcloud docker -- push eu.gcr.io/my-project/ubuntu-gcloud
</code></pre>

<p>If you want to use regular docker commands, update your docker configuration with GCR credentials:</p>

<pre><code>gcloud docker -a
</code></pre>

<p>Then you can build and push docker images like this:</p>

<pre><code>docker build -t eu.gcr.io/my-project/ubuntu-gcloud .
docker push eu.gcr.io/my-project/ubuntu-gcloud
</code></pre>
