You are not logged in.

#1 2025-01-22 13:56:15

kreshta
Member
Registered: 2017-08-22
Posts: 31

Docker requires sudo to run, even though USER is in the docker group.

When running

> sudo docker run hello-world

I get the welcome message. However, if I run

> docker run hello-world

I get

docker: Cannot connect to the Docker daemon at unix:///home/d/.docker/desktop/docker.sock. Is the docker daemon running?

Online forums suggested that is could be a permission issue. However, if I run

> groups $USER

I get

wheel docker d

So it appears like I am in the proper group. What else could be the issue?

Offline

#2 2025-01-22 14:45:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,075

Re: Docker requires sudo to run, even though USER is in the docker group.

Is the docker daemon running? The user group is only relevant so you can actually connect to the instance assuming it's running. Output of

systemctl status docker

? did you reboot/restart docker after adding your user to the group? I also wonder why it tries to connect to a user local socket here...

Last edited by V1del (2025-01-22 14:46:25)

Offline

#3 2025-01-22 15:08:09

kreshta
Member
Registered: 2017-08-22
Posts: 31

Re: Docker requires sudo to run, even though USER is in the docker group.

It says that it is "active (running)". Why would it not? Docker works with sudo. Is it possible for it to work with sudo if the docker daemon is not running?

I just rebooted my laptop, and that did not fix the issue.

Offline

#4 2025-01-22 15:51:42

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,075

Re: Docker requires sudo to run, even though USER is in the docker group.

the main question is why it tries to look at your home dir instead of the socket file /var/run/docker.sock which would allow you access. Are you exporting some env variable or so?

printenv

Offline

#5 2025-01-22 16:04:30

kreshta
Member
Registered: 2017-08-22
Posts: 31

Re: Docker requires sudo to run, even though USER is in the docker group.

running

env DOCKER_HOST=unix:///var/run/docker.sock docker ps

works. Normally DOCKER_HOST is not defined

Offline

#6 2025-01-22 16:35:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,075

Re: Docker requires sudo to run, even though USER is in the docker group.

feels like a docker CLI bug, it should look there by default (or at least try to look there after $HOME/.docker failed) instead of randomly guessing something in your $HOME dir.

Offline

#7 2025-01-23 06:10:51

kreshta
Member
Registered: 2017-08-22
Posts: 31

Re: Docker requires sudo to run, even though USER is in the docker group.

I'll report it in their forums. Thanks

Offline

#8 2025-08-01 22:49:52

watermelon77872
Member
Registered: 2025-08-01
Posts: 1

Re: Docker requires sudo to run, even though USER is in the docker group.

After installing Docker with the official (experimental) Docker Desktop and failing the binary installation, I encountered a similar issue, as I had two Docker contexts despite the failed installation process.


docker context ls

docker context use default

docker context rm desktop-linux

Offline

#9 2025-12-10 11:00:52

devadamking
Member
Registered: 2025-12-10
Posts: 1

Re: Docker requires sudo to run, even though USER is in the docker group.

watermelon77872 wrote:

After installing Docker with the official (experimental) Docker Desktop and failing the binary installation, I encountered a similar issue, as I had two Docker contexts despite the failed installation process.


docker context ls

docker context use default

docker context rm desktop-linux

Having multiple contexts, especially as above, was the issue for me - since it seems nobody replied to confirm this.
Thank you!

Offline

#10 2025-12-10 13:26:10

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,356
Website

Re: Docker requires sudo to run, even though USER is in the docker group.

Mod note: Closing this old thread.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB