dev-environments icon indicating copy to clipboard operation
dev-environments copied to clipboard

Got permission denied while trying to connect to the Docker daemon socket after restarting Docker for Desktop

Open kantesilvestrs opened this issue 3 years ago • 4 comments

Describe the bug Dev environment throws 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/version": dial unix /var/run/docker.sock: connect: permission denied message when trying to interact with docker, e.g. docker stats after Docker for Desktop has been restarted.

To Reproduce Steps to reproduce the behavior:

  1. Create new dev environment
  2. Open environment in VS Code
  3. Run command docker stats from VS Code terminal to see current running containers
  4. Close VS Code
  5. Restart Docker for Desktop
  6. Open dev environment in VS Code
  7. Run command docker stats from VS Code terminal
  8. Now an error message is displayed 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/version": dial unix /var/run/docker.sock: connect: permission denied

Expected behavior Running docker commands after Docker for Desktop restart should yield same results when the dev environment is just created and launched.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 10.0.22000 Build 22000

Version of Docker Desktop:
You can find the version by clicking on the About Docker Desktop menu

Version

4.7.0 (77141)

Engine: 20.10.14

Compose: 1.29.2

Credential Helper: v0.6.4

Kubernetes: v1.22.5

Snyk: v1.827.0

Additional context I noticed this issue while trying to run a docker instance from the dev environment

kantesilvestrs avatar Apr 15 '22 11:04 kantesilvestrs

Is there any update on this? I have the same issue. On restart my dev environment user requires sudo with docker commands

htcarr3 avatar Aug 16 '22 23:08 htcarr3

I also have this issue. When trying to perform docker commands I get permission denied. I have tried adding the user to the docker group, which seems to exist, but this asks for a password, which I dont have

KieranJeffreySmart avatar Sep 12 '22 10:09 KieranJeffreySmart

I am also facing the same issue. After some troubleshooting I noticed two very suspicious things:

  1. When I am checking if vscode user is part of docker group though group command, it looks like it is not. However, I also looked inside /etc/group file and vscode user is included there:
...
docker:x:1001:vscode
...
  1. The owner user and group of docker socket are both set to root. I changed group to docker, however (because of 1. most probably) it did not solve the issue.

jw-websensa avatar Nov 15 '22 13:11 jw-websensa

It looks like the gid of docker.sock is now set to 800 whenever you start up your VM. If they don't match, then you're going to have problems. We now have this line in our Dockerfile to build the base image:

RUN groupadd docker -g 800

This has solved the docker permissions issue for us.

jfrumar-infinitusai avatar Nov 16 '22 21:11 jfrumar-infinitusai