4

I use Ubuntu 20.04 and I use docker to run images. When I installed and ran the docker command for the 1st time, the following error occurred in the shell.

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

I ran sudo chmod 766 /var/run/docker.sock and it worked. However, whenever I restart the system, I have the permission denied again and I need to run chmod again.

How do I resolve this issue? I want to have root access always when running docker

Artur Meinild
  • 26,018
at8819
  • 43

1 Answers1

5

You have to add your user to the docker group by running:

sudo usermod -a -G docker $USER

the new group membership will be applied to your user after logging out and back in again.

For reference, see the official docker installation guide

pzkpfw
  • 5,632
N0rbert
  • 99,918