-
Notifications
You must be signed in to change notification settings - Fork 118
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
Bind-mounted volume has owner:group set as root when running container as non-root user #5480
Comments
I'm facing the exact same issue. I don't know why the bind mounted volume is owned by root:root and then after doing an ls of this directory the ownership is set to the user and group it's supposed to be. |
I don't think this is completely specific to docker for mac. Also getting this on Docker 20.10.7 on Linux, although I don't get the weird error with the ownership fixing itself. It just stays broken. |
I agree, in fact I noted that this also happens on Windows with WSL. I was directed to make the post here. A link to my original comment is here moby/moby#3124 (comment) |
Experiencing the same issue with Docker Desktop (Docker Engine v20.10.8) and WSL2 (Ubuntu filesystem) on Windows 10. Dockerfile does When I login into the container without mounting the folder, the owner of When I mount Moreover my WSL2 Linux user that I run |
We faced the same issue with Docker for Mac 4.0.1 (Engine 20.10.8) and for us deactivating "Use gRPC FUSE for file sharing" fixed the problem. I also tried exactly the same steps as @noahjahn and had similar results. Only the steps 6 and 7 did not work. |
Issues go stale after 90 days of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
/remove-lifecycle stale |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
5C4B7958-B047-4869-8386-358281ABB1F5/20210319155312
Expected behavior
Running a docker image as a non-root user and bind-mounting a directory in the container at run time should should have the bind-mounted directory in the container's permissions set as the owner and group of the user specified in the Dockerfile image.
Actual behavior
Running a docker image as a non-root user and bind-mounting a directory in the container at run time should should have the bind-mounted directory in the container's permissions set as the owner and group of
root
until the bind-mounted directory has some sort of action happen within the container. See steps 5, 6, and 7 below.Information
This problem is reproducible, though I'm not sure if it's a new problem. I also made a post here: moby/moby#3124 (comment) and was directed to post on this project instead.
I've tested the following on:
AND:
Steps to reproduce the behavior
For a very simple test, let's say there is a configuration directory on my host user's home directory that I want a running container to be able to modify. Let's call this directory
~/.myconf
.If you're testing this yourself, make this directory in your user profile with
mkdir ~/.myconf
.Create a Dockerfile somewhere that looks like this (here is a simple Dockerfile to add and use a non-root user):
docker build -f Dockerfile -t app .
~/.myconf
directory on the host machine to the/home/appuser/.myconf
in the container:docker run -it -v "$HOME/.myconf":/home/appuser/.myconf app /bin/sh
Notice how it shows that the bind mounted directory
/home/appuser/.myconf
is owned byroot
. The group is also set asroot
:ls -al /home/appuser/.myconf > /dev/null
This actually CHANGES the owner and group to be the correct user and group who should have access to the
/home/appuser/.myconf
directory.ls -al
again after running the previous command:The text was updated successfully, but these errors were encountered: