Fixing 'Got permission denied while trying to connect to the Docker daemon socket'


If your current user can't access the docker engine you will get permission errors while running anything with docker processes.

Ex. docker ps

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: 
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json: 
dial unix /var/run/docker.sock: connect: permission denied

Ex. docker kill $(docker ps -q)

$ docker kill $(docker ps -q)
Got permission denied while trying to connect to the Docker daemon socket at 
unix:///var/run/docker.sock: 
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json: 
dial unix /var/run/docker.sock: connect: permission denied
"docker kill" requires at least 1 argument.
See 'docker kill --help'.

Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill one or more running containers

To avoid these permission issues run the following command

sudo chmod 666 /var/run/docker.sock