Search code examples
docker

I don't have permission to access Docker and every new terminal instance I need to run newgrp docker


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?


Solution

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