4

I installed Docker as per suggestion on the official website. I ran into problems regarding permissions of the .sock file.

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:25:55 2020
 OS/Arch:           linux/amd64
 Experimental:      false
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.40/version: dial unix /var/run/docker.sock: connect: permission denied

I already created and recreated the docker group as well as my user to the group and logged out many times, all to continue resulting in the above error. The only thing that "solves" is running newgrp docker, but it then only works for that instance of the terminal.

How do I prevent this? I don't want to add that command to my .zshrc. It has always worked just by adding my user to the docker user.

Edit

I noticed that when running groups, docker is not there despite the thousands attempts to add my user to it. Why?

  • Humm that's weird... Can you check in your `/etc/group` file that your user is really in the docker group ? – Marc ABOUCHACRA Apr 02 '20 at 12:29
  • Ok, just saw the edit, can you post the command you used to add your user to the `docker` group then ? – Marc ABOUCHACRA Apr 02 '20 at 12:31
  • It shows `docker:x:1001:` only; and the commands I tried were these: `sudo usermod -aG docker gabriel`, `sudo usermod -a -G docker gabriel` and `sudo usermod -G docker -a 'gabriel'`, Three, and none worked. I don't know why it began to be like this. It used to be so simple. –  Apr 02 '20 at 12:34
  • And (just to be sure) when you do `echo $USER` it prints `gabriel` right ? – Marc ABOUCHACRA Apr 02 '20 at 12:39
  • Yes it does print gabriel –  Apr 02 '20 at 12:40
  • Hey, I solved it with this command: `sudo setfacl -m user:gabriel:rw /var/run/docker.sock`. –  Apr 02 '20 at 12:44
  • Does this answer your question? [Permission denied to Docker daemon socket at unix:///var/run/docker.sock](https://stackoverflow.com/questions/53126950/permission-denied-to-docker-daemon-socket-at-unix-var-run-docker-sock) – gmarmstrong Apr 26 '22 at 18:24

1 Answers1

9

I solved it with this command: sudo setfacl -m user:gabriel:rw /var/run/docker.sock

  • This works for me. A more general command would be: sudo setfacl -m user:$USER:rw /var/run/docker.sock – avatar Jul 01 '23 at 09:49