<p>I have a setup where docker ONLY works as root (I know, my fault). I'm trying to follow the GCR quickstart: [1]. I can't find anything on the troubleshooting page [2] either.</p>

<p>Can you help me (and I can then file a document fix)?</p>

<p>[1] <a href="https://cloud.google.com/container-registry/docs/quickstart" rel="nofollow noreferrer">https://cloud.google.com/container-registry/docs/quickstart</a>
[2] <a href="https://cloud.google.com/container-registry/docs/support/troubleshooting" rel="nofollow noreferrer">https://cloud.google.com/container-registry/docs/support/troubleshooting</a></p>

<h1>Repro</h1>

<p>Reproduction steps (also in b/68796816):</p>

<pre><code>$ docker -v
Docker version 1.6.2, build 7c8fca2
ricc@rubino:~/git/gce-recipes/gke/quickstart-image$ sudo docker run busybox date
Thu Nov  2 12:29:35 UTC 2017
$ sudo docker tag quickstart-image gcr.io/ric-cccwiki/quickstart-image 
# All good so far ...
</code></pre>

<p>Option 1 (no sudo):</p>

<pre><code># no sudo: docker doesn't work
$ gcloud docker -- push gcr.io/ric-cccwiki/quickstart-image
FATA[0000] Post http:///var/run/docker.sock/v1.18/images/gcr.io/ric-cccwiki/quickstart-image/push?tag=: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS? 
</code></pre>

<p>Option 2: with sudo:</p>

<pre><code># docker works but gcloud is not found
$ sudo gcloud docker -- push gcr.io/ric-cccwiki/quickstart-image
sudo: gcloud: command not found
</code></pre>

<p>Neither way works</p>

<p>Jake suggests: <code>gcloud docker</code> is on the deprecation path, for this reason among others. </p>

<p>I'd recommend doing <code>gcloud components install docker-credential-gcr</code> 
followed by <code>which docker-credential-gcr</code>, <code>cp</code>ing the binary to a location 
on root's PATH. </p>

<p><code>sudo docker-credential-gcr configure-docker</code> followed by 
<code>sudo docker-credential-gcr gcr-login</code> should then allow you to use <code>sudo 
docker</code> without issue.</p>

<p>See credentials helper's docs:
<a href="https://github.com/GoogleCloudPlatform/docker-credential-gcr" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/docker-credential-gcr</a></p>
