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

If you are getting an error running the docker command as a non-root user,

[email protected]:~$ 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.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied
[email protected]:~$ 


Solution: Provide group permission and docker.sock file permission.

Solution #1: Run the command using sudo

sudo docker <COMMAND>

Example for running the docker command using sudo:

[email protected]:~$ sudo docker run hello-world

Solution #2: Add user to docker group

Provide group permission and docker.sock file permission by creating user-group docker and add the user to it

# Creating a group - docker
sudo groupadd docker

# Adding user to the group "docker"
sudo usermod -aG docker $USER

Provide read write permission to docker.sock file

The below will fix the error, docker: Got permission denied while trying to connect to the Docker daemon socket

sudo chmod 666 /var/run/docker.sock


Official documentation on post-install tasks, https://docs.docker.com/engine/install/l…stinstall/