-
Notifications
You must be signed in to change notification settings - Fork 3
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
Permission Errors in Container Due to UID Mismatch When Host UID Is Not 1000 #53
Comments
Maybe we can refer to how devcontainer handles this issue. After building the image, they check whether the user UID inside image matches the local one. If it doesn’t, they create a temporary image based on that one, directly forcing the UID to match the local UID. You can refer to the
However, forcibly modifying the image’s UID/GID could potentially introduce some issues. See #45 and this comment for more details. |
The UID mismatch between the host and container can cause the A simple workaround is to change the ownership of the entire workspace directory to UID 1000: # in the container, at the default workdir
sudo chown -R 1000 . I believe this is the current recommended approach. Although this resolves permission issues in the container, it makes modifying files from the host more difficult. (requires undoing the above To allow direct file modifications on the host, it is preferred to keep the file owner as the host user. Currently I can think of two approaches that can support this:
PS. Creating a temporary Docker image doesn’t seem like a good solution, as it requires manual builds across multiple machines, which can be quite cumbersome. |
In Ubuntu 20.04 or 22.04, the default user UID is 1000, when creating the default user in the Dockerfile, we also use 1000 as our default UID. However, in Ubuntu 24.04, the default UID has been changed to 1001, as UID 1000 is already occupied by a pre-existing user. While we can delete that default user and create our own, when we mount local files into the Docker container, we won’t be able to modify them because those files are owned by UID 1001, leading to many inconveniences during development.
This issue also occurs on servers. As long as our local user UID is not 1000, we won't be able to use our Dockerfile properly.
The simplest solution for now is to ask users whose UID is not 1000 to manually modify the default UID in the Dockerfile and build the Docker image themselves. However, this solution is somewhat inconvenient. We might need to think of a better approach in the future.
The text was updated successfully, but these errors were encountered: