Docker: Got permission denied while trying to connect to the Docker

Views: 27
0 0
Read Time:52 Second

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
d3@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

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
run Chrome without CORS Previous post How to run Chrome without CORS
Import a docker image in kubernetes Next post Import a docker image in kubernetes
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x