Got permission denied while trying to connect to the Docker daemon socket after restarting Docker for Desktop
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:
- Create new dev environment
- Open environment in VS Code
- Run command
docker statsfrom VS Code terminal to see current running containers - Close VS Code
- Restart Docker for Desktop
- Open dev environment in VS Code
- Run command
docker statsfrom VS Code terminal - 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

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
Is there any update on this? I have the same issue. On restart my dev environment user requires sudo with docker commands
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
I am also facing the same issue. After some troubleshooting I noticed two very suspicious things:
- When I am checking if
vscodeuser is part ofdockergroup thoughgroupcommand, it looks like it is not. However, I also looked inside/etc/groupfile andvscodeuser is included there:
...
docker:x:1001:vscode
...
- The owner user and group of docker socket are both set to
root. I changed group todocker, however (because of 1. most probably) it did not solve the issue.
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.