How Do You Troubleshoot the Error “Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock”?

Problem scenario
You try to run a Docker command, but you get this error: 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.29/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied

What should you do?

Solution
Have you added the user who was trying to execute the command to the "docker" group?

This command would add the user jdoe to the "docker" group:
sudo usermod -aG docker jdoe

If you ran the above command as the jdoe user, log out and log back in.

It is not advisable to run "docker" commands with "sudo " before them. In rare cases it may be necessary to use it to get the "docker" command to work.

For troubleshooting similar errors you may want to click on one of the following:

Leave a comment

Your email address will not be published. Required fields are marked *