-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: Docker 4.19.0 permission denied for /var/run/docker.sock when using Docker in Docker #6823
Comments
Removing the |
Hi @ericvn , can I close this issue ? Or is there anything we can help with here ? |
I tried with build 4.18.0 (104112) but I couldn't get it to work then either:
Possibly the change is in the |
I will try and install an older version over 4.19 (is that supported) to verify that 4.18 and/or 4.17 works. Unfortunately, I don't have a laptop to fresh install to verify. Note that this also happened back in the 2.3 days: #4755 |
I just created an issue for this too. Here is my notes of my issue. Same problem on MAC and Windows. Docker desktop version 4.19.0 broke my -v /var/run/docker.sock.raw /var/run/docker.sock. About 2 years ago, this solved my docker socket permission denied error (See belwo).... It was working fine up through version 4.18, but after the v4.19 upgrade, it broke again. Getting this error again. Had to revert back to version 4.18. Same issue on Windows and Mac versions.
Again, no issues until I went to docker desktop version 4.19 and its the same issue on MAC and WINDOWS. The docker.sock.raw was the only viable option for me to fix this. Mac Version: Ventura 13.3 |
Actually to get it to work on 4.18 or earlier you need to specify the -v /var/run/docker.sock.raw:/var/run/docker.sock If you look in my earlier PR, the .raw was needed after 2.6.? maybe. It had worked until 4.19. |
Prior to 4.19.0, a non-root user could be used, but the user had to be in the root group. Also, you needed to mount With 4.19.0, only the root user seems to work. I have had to downgrade back to 4.18.0 to get this working again. There are lots of reasons to run as a non-root user. In fact that should be the norm. In one use case I have, I use a container for building, and run as a host user, so that files can be written to bind mounted volumes. Part of the build process involves creating images, so it needs Docker access also. |
First of all, this scenario is not "Docker in Docker"; the In regular setups (plain, non-Docker-Desktop "Linux" installation), access to the docker socket should be protected, as having access to the docker engine API (through On Docker Desktop, the security model is somewhat different, as the VM acts as an extra security boundary; while the Docker Engine runs as For reasons above, permissions of the docker socket on the host (macOS, Windows) can be more permissive than on a Linux machine, allowing non-root users to connect to the Docker API.
I don't think this would be related to changes in the Now the questions are;
Looking at permissions on a Linux machine: ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 Dec 10 2020 /var/run/docker.sock
cat /etc/group | grep docker
docker:x:999:sebastiaan (I added myself to the Or (showing numeric UID/GID), on this machine the ls -ln /var/run/docker.sock
srw-rw---- 1 0 999 0 Dec 10 2020 /var/run/docker.sock Comparing this to permissions of the socket inside the Docker Desktop VM, I see ls -l /var/run/docker.sock
srwxr-xr-x 1 root root 0 May 5 00:39 /var/run/docker.sock
cat /etc/group | grep docker
# no result Differences worth noting here;
On a Linux machine, that also means I won't be able to access the socket as a non-root user, as it's protected by its Linux permissions; Using the UID/GID I have on the host ( id
uid=1000(sebastiaan) gid=1000(sebastiaan) groups=1000(sebastiaan),999(docker) docker run -v /var/run/docker.sock:/var/run/docker.sock -u1000 -it --rm docker version
Client:
Version: 23.0.5
API version: 1.42
Go version: go1.19.8
Git commit: bc4487a
Built: Wed Apr 26 16:12:25 2023
OS/Arch: linux/amd64
Context: default
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 But, running with the docker run -v /var/run/docker.sock:/var/run/docker.sock -u1000:999 -it --rm docker version
Client:
Version: 23.0.5
API version: 1.42
Go version: go1.19.8
Git commit: bc4487a
Built: Wed Apr 26 16:12:25 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 23.0.4
... docker run -v /var/run/docker.sock:/var/run/docker.sock -u1000:1000 --group-add 999 -it --rm docker version
Client:
Version: 23.0.5
API version: 1.42
Go version: go1.19.8
Git commit: bc4487a
Built: Wed Apr 26 16:12:25 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 23.0.4
... So, what changed?Not entirely sure.
Things to look intoI think we should look into the permissions of the socket inside the VM, and the missing
With that, I think access to the socket within the VM would still be protected "by default", but it would be possible to access the socket by passing the # run with the same UID and GID as the user on the host, but add the docker group's GID as auxiliary group
docker run -v /var/run/docker.sock:/var/run/docker.sock -u"$(id -u):$(id -g)" --group-add 999 -it --rm docker version |
The socket permissions in the VM seem to have changed between 4.18.0 and 4.19.0 4.18.0 $ nc -U ~/Library/Containers/com.docker.docker/Data/debug-shell.sock <<< "ls -lL /var/run/docker.sock"
/ # ^[[47;5Rls -lL /var/run/docker.sock
srw-rw---- 1 root root 0 May 7 15:03 /var/run/docker.sock 4.19.0 $ nc -U ~/Library/Containers/com.docker.docker/Data/debug-shell.sock <<< "ls -lL /var/run/docker.sock"
/ # ^[[47;5Rls -lL /var/run/docker.sock
srwxr-xr-x 1 root root 0 May 7 21:17 /var/run/docker.sock It seems to no longer have write permissions for the root group. I was previously able to access when the root group id was used (which I usually did with Now the the 4.19.0 changes, it looks like being the root user is the only way to access the docker socket. |
This is still broken in 4.20.0. As a reminder, I would expect this command to work, as it did prior to 4.19.0:
This runs the container using the host user's id/group, but adds it to the root group also. From 4.19.0, you need to be the root user, which breaks a lot of use cases. |
Hi everyone. FYI, a fix is being tested. |
I can confirm that with 4.21.0 that this appears fixed. I can now execute docker commands within the container provided I add my user to the root group. |
We have released Docker desktop 4.21.1, containing a fix for this issue, please see https://docs.docker.com/desktop/release-notes/ |
Expected behavior
Using Docker in Docker should work the same as in prior versions, like 4.18.0
Actual behavior
Docker 4.19.0:
Docker 4.18.0:
Information
Output of
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
Steps to reproduce the behavior
The text was updated successfully, but these errors were encountered: