Share this content:
I hit so many times this issue that I’m nearly sure you too! Bookmark this page because in this article we are going to fix the issue with Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
I have a freshly installed docker in Ubuntu 20.04 LTS and straight after the installation I run
$ sudo snap install docker
docker 20.10.14 from Canonical✓ installed
brewedbrilliance@my-local-k3s:~$ 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
So to fix got permission denied you just need to run these 2 commands
$ sudo groupadd docker
$ sudo usermod -aG docker ${USER}
Reboot your machine (newgrp will not work with ubuntu 20) and login again
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Job done!
Help us grow by sharing this article