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.
Can you help me (and I can then file a document fix)?
[1] https://cloud.google.com/container-registry/docs/quickstart [2] https://cloud.google.com/container-registry/docs/support/troubleshooting
Reproduction steps (also in b/68796816):
$ 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 ...
Option 1 (no sudo):
# 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?
Option 2: with sudo:
# docker works but gcloud is not found
$ sudo gcloud docker -- push gcr.io/ric-cccwiki/quickstart-image
sudo: gcloud: command not found
Neither way works
Jake suggests: gcloud docker
is on the deprecation path, for this reason among others.
I'd recommend doing gcloud components install docker-credential-gcr
followed by which docker-credential-gcr
, cp
ing the binary to a location on root's PATH.
sudo docker-credential-gcr configure-docker
followed by sudo docker-credential-gcr gcr-login
should then allow you to use sudo docker
without issue.
See credentials helper's docs: https://github.com/GoogleCloudPlatform/docker-credential-gcr
There are a few options, the best being to just make docker usable without root: https://docs.docker.com/engine/installation/linux/linux-postinstall/
Option 1: Specify your full path to gcloud when using it.
sudo $(which gcloud)
Option 2: Install glcoud as root
sudo su
#install gcloud
gcloud version
However, the best thing to do is to just use docker as non-root :)