Docker Got permission denied while trying to connect to the Docker daemon socket at unix

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See ‘docker run –help’.

 

To fix this issue, we have to create a group, assign the user to the group and then give the permissions to /var/run/docker.sock

 

Add docker group

$ sudo groupadd docker

Add your current user to the docker group

$ sudo usermod -aG docker $USER

Switch session to the docker group

$ newgrp - docker

Run an example to test

$ docker run hello-world

 

Still, if you are facing the permission denied error, then give the permission to /var/run/docker.sock like as follows.

Give Permissions

sudo chmod 666 /var/run/docker.sock

And then try again docker run hello-world 

 

 

Leave a Reply