środa, 28 stycznia 2015

Why running docker command returns "/var/run/docker.sock: permission denied"

/var/run/docker.sock: permission denied

$ docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.16/containers/json: 
dial unix /var/run/docker.sock: permission denied.
Are you trying to connect to a TLS-enabled daemon without TLS?
First quick look at the /var/run/docker.sock file.
$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 sty 28 11:53 /var/run/docker.sock
The solution should be now clear - you can solve the issue by adding user you are logged in to the docker group.

So, let's do this:

$ sudo gpasswd -a ${USER} docker
There should be now a change in /etc/group file.
$ cat /etc/group | grep ^docker
Next you need start new terminal session to apply the change and check if you are in the docker group. Should be listed in the following command execution:
$ groups
If still cannot see docker in the groups you're in - and you run linux with graphical interface (eg Ubuntu) you may need basically restart machine. Once done restart your docker container (if you were not needed restarting machine in previous step ;)
$ sudo service docker.io restart
That's all, now docker ps should be no problem to run.

2 komentarze: