question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WSL /var/run/docker.sock permissions

See original GitHub issue

Rancher Desktop Version

0.7.1

Rancher Desktop K8s Version

1.22.5

What operating system are you using?

Windows

Operating System / Build Version

Windows 10

What CPU architecture are you using?

x64

Windows User Only

No response

Actual Behavior

Cannot use docker as a regular ubuntu user.

Steps to Reproduce

  • Install WSL 2
  • Install Ubuntu 20.04
  • Create the default Ubuntu user
  • Install Rancher Desktop
  • Enable Rancher Desktop integration with Ubuntu 20.04
  • Open WSL inside Ubuntu 20.04
  • Execute docker ps

Result

rgl@xxx:~$ 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

rgl@xxx:~$ ll /var/run/docker.sock
srwxr-xr-x 1 root root 0 Dec 23 11:34 /var/run/docker.sock=

rgl@xxx:~$ id
uid=1000(rgl) gid=1000(rgl) groups=1000(rgl),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev)

Expected Behavior

To be able to use docker as a regular user.

Maybe put the docker socket in a docker group and set its permissions to rwxrwxr-x root docker.

Additional Information

Running docker ps from Windows (e.g. from a powershell session) works fine.

But running docker ps from within WSL Ubuntu does not work.

It also fails to work when I add my user to the root group:

rgl@xxx:~$ docker ps
request returned Bad Gateway for API route and version http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json, check if the server supports the requested API version

rgl@xxx:~$ id
uid=1000(rgl) gid=1000(rgl) groups=1000(rgl),0(root),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

19reactions
ericpromislowcommented, Jan 20, 2022

This looks like it’ll work:

sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL
sudo chown root:docker /var/run/docker.sock
sudo chmod g+w /var/run/docker.sock
2reactions
rglcommented, Dec 24, 2021

After creating the docker group and adding me:

$ sudo groupadd --system docker
$ sudo usermod -aG docker rgl
$ exit
$ id
uid=1000(rgl) gid=1000(rgl) groups=1000(rgl),0(root),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),116(admin),117(netdev),999(docker)

The socket now has the correct permissions:

$ ll /var/run/docker.sock
srwxrwxr-x 1 root docker 0 Dec 24 05:58 /var/run/docker.sock=

Thanks for pointing that out!

Though it still fails with the error that I’ve pointed before:

$ docker ps
request returned Bad Gateway for API route and version http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json, check if the server supports the requested API version
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "dial unix /var/run/docker.sock: connect
Just try to give the right permission to docker.sock file by: ... Ubuntu 18:04 sudo setfacl --modify user:$USER:rw /var/run/docker.sock.
Read more >
How to fix docker: Got permission denied while trying to ...
sock : connect: permission denied. See 'docker run --help'. Solution:permissions of the socket indicated in the error message, /var/run/docker.
Read more >
How to Fix Docker Permission Denied Error on Ubuntu
Got permission denied while trying to connect to the Docker daemon socket at ... sudo chown root:docker /var/run/docker.sock.
Read more >
How to fix "Got permission denied while trying to connect to ...
Quickest way to fix How to fix “Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: ...
Read more >
Docker WSL permission issues
I am currently running Docker version 19.03.1, build 74b1e89. ... "Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found