Cannot use docker without sudo privilege after following the official guide

104 Views Asked by At

I am trying to pull a Docker image by this command docker pull rabbitmq then I got this error Cannot connect to the Docker daemon at unix:///home/nickie/.docker/desktop/docker.sock. Is the docker daemon running?

When I ran sudo system ctl status docker the status was green (active and running)

I've then followed all the threads I could find on this platform, but no solutions solved my issue.

When I run sudo groupadd docker following this guide the console replied groupadd: group 'docker' already exists but even when I uninstalled Docker completely from Ubuntu and reinstall it from scratch, the issues reappeared.

Yes I can add "sudo" before any docker command I try to execute and the issue could go away, but I remember I did not have to do this in previous times when I installed Docker on other computers. So I need an explanation why this issue happened and how I could fix it.

Other threads I've visited: Docker: executng commands with non-root user inside container, How to fix docker: Got permission denied issue, Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock, Docker Permission Denied During Setup

1

There are 1 best solutions below

2
On

Your user likely isn't in the docker group (see with groups)

usermod -aG docker $USER

If you have done this and it still doesn't work, you may need to sign out and back in or start a login shell to refresh the permissions