5

I have installed Docker Rancher on Windows 10 with dockerd option and WSL on true for my current WSL distribution (Ubuntu). When i try to use docker in WSL2, I had the following error:

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

The command works fine in the cmd shell.

Which kind of permission I'm missing?

erKito
  • 303
  • 2
  • 9

1 Answers1

20

The issue is that Docker Rancher installer do not create the docker group. Use the following commands:

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

thanks to https://github.com/rancher-sandbox/rancher-desktop/issues/1156#issuecomment-1017042882

erKito
  • 303
  • 2
  • 9
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 11:08