Fix How To Ubuntu

How To Fix ‘Got permission denied while trying to connect to the Docker daemon socket’ Error In Ubuntu

How To Fix ‘Got permission denied while trying to connect to the Docker daemon socket’ Error In Ubuntu
Written by itsubuntu

Last Updated on April 16, 2023 by itsubuntu

How To Fix ‘Got permission denied while trying to connect to the Docker daemon socket’ Error In Ubuntu 22.04 LTS

If are you going through the following issue while trying to run Docker on Ubuntu 22.04 LTS or in any other version of Ubuntu then you are in the right place. We have the solution for 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.39/containers/json: dial unix /var/run/docker.sock: connect: permission denied

How To Fix ‘Got permission denied while trying to connect to the Docker daemon socket’ Error In Ubuntu 22.04 LTS

This is one of the strange issues that we had while using Docker.  We have two methods to solve this error.

Running docker commands without sudo

First, create the docker group using the following groupadd command. After running the command, add your user account to this group with another command.

sudo groupadd docker
sudo usermod -aG docker $USER

Now You won’t have any issues even if you try running the docker commands without sudo.

Run all the docker commands with sudo

Another solution is to run the docker command with sudo privilege.

About the author

itsubuntu

Leave a Comment