Closed PhilDay-CT closed 2 months ago
We started seeing this issue after upgrading our dev container base from Ubuntu 22.04 to 24.04. The 22.04 base image has no existing users and so creating a non-root user gives a UID of 1000, with 24.04 there's an ubuntu
user with UID 1000 so our UID is 1001. This has probably been broken for a while but was hidden by the fact that all of the people using our dev container on Linux use the first interactive user ID, which happened to match the user in the container.
We can work around it somewhat by forcing the UID of the user in the container to 1000, but that is just masking the problem.
I have run into this issue on Ubuntu and MacOS hosts. I think this will particularly affect MacOS users, because MacOS assigns users to the staff
group which is a different ID than the user ID, and the user ID is not 1000
or 1001
by default, as it is in Ubuntu. It seems that updateRemoteUserId
has no effect.
I encountered the same issue, my host uid/gid was 1000/1001. I added
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
# Workaround for remoteuser id issue
# https://github.com/microsoft/vscode-remote-release/issues/10030
RUN usermod -u 2000 ubuntu && groupmod -g 2000 ubuntu
...
to the top of the devcontainer Dockerfile as a temporary workaround.
We don't update the UID when there already is a user with that UID. In this case Ubuntu 24.04 already has a user with UID 1000, so the UID 1001 user can't be updated to use UID 1000.
@samruddhikhandale This might be tricky to work around in the CLI because it might encounter various base images. Maybe we can work around it in our base images either by removing the ubuntu
user or by updating its UID and GID to one that is unlikely to cause a conflict.
There are instructions in the advanced section for creating non-root users. https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user. It has a section on editting the UID/GID when creating an image https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_change-the-uidgid-of-an-existing-container-user but not if the base-image includes conflicting accounts. At the moment, suggestions that pop up when you search
dev containers eaccess permission
or
dev containers uid and gid don't match
in a search engine don't direct to this documentation and the results that do aren't very useful (other than this issue popping up). Maybe the documentation can be updated to mention these terms for SEO.
@samruddhikhandale This might be tricky to work around in the CLI because it might encounter various base images. Maybe we can work around it in our base images either by removing the
ubuntu
user or by updating its UID and GID to one that is unlikely to cause a conflict.
When noble was released, we had a long discussion regarding how to handle it and we ended up with a collective decision of letting the vscode
user be 1001
for noble distro and letting focal and jammy have vscode:1000
Sharing the couple of reasons we thought this was the right way -
@chrmarti It's been three months since we released base images with ^, not sure what's the best way is to handle it. We can still make changes given the fact that noble
is not yet latest
for the base
image. Also, we have seen https://github.com/devcontainers/images/issues/1056
Let me know what you think!
Given that this breaks our fix for the workspace file ownership mismatch on Linux (the UID updater) for local UID 1000, I suggest we reconsider our options. We decided to keep the ubuntu
user unchanged under the assumption that this would avoid interfering with the base image's setup. I think we probably just delete this user as suggested in https://github.com/devcontainers/images/issues/1056 and then create the vscode
user as before (UID 1000 will be reused in this case).
Some background on the ubuntu user: https://bugs.launchpad.net/cloud-images/+bug/2005129
We decided to keep the ubuntu user unchanged under the assumption that this would avoid interfering with the base image's setup.
Yes, that was definitely our thoughts there.
I think we probably just delete this user as suggested in https://github.com/devcontainers/images/issues/1056 and then create the vscode user as before (UID 1000 will be reused in this case).
Makes sense, thanks!
Continuing in https://github.com/devcontainers/images/issues/1056. Thanks.
I'm running a dev container created from a base Ubuntu 24:04 image with and additional user account
On my host system my user id is 1000
Using this with the following devcontainer.json I was expecting the updateRemoteUserUID option to update the UID/GID to match my local UID/GID - which as per (https://containers.dev/implementors/json_reference/) I need to avoid permission issues in the mount, but it doesn't happen.
When I open a terminal in VSCode in the Docker the id is still set to guest
VSCode Version: Version: 1.90.2 Commit: 5437499feb04f7a586f677b155b039bc2b3669eb Date: 2024-06-18T22:33:48.698Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.5.0-35-generic snap
Local OS Version:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy
$ uname -a Linux 7558979553bb 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux