Skip to content
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

uid mapping problem with ubuntu-24.04 base image #1056

Open
MawKKe opened this issue May 8, 2024 · 5 comments
Open

uid mapping problem with ubuntu-24.04 base image #1056

MawKKe opened this issue May 8, 2024 · 5 comments

Comments

@MawKKe
Copy link

MawKKe commented May 8, 2024

Problem

Using image ubuntu-24.04 (latest/dd2da503391d) as base for a devcontainer builds and launches normally, but the vscode user cannot create or modify files due to the fact that vscode uid is 1001 and the mounted workspace is owned by uid 1000.

(I am unsure how the ID mapping works between host and container; my host user also happens to have uid 1000, which might obfuscate the underlying issue. )

The problem seems to be caused by the image containing extra user named ubuntu that has been given the uid 1000 before user vscode has been created. I can create an modify files as that user via sudo su - ubuntu.

The problem does not appear with to ubuntu-22.04 or earlier, which do not have the extra ubuntu user:

$ docker run -it --rm mcr.microsoft.com/devcontainers/base:ubuntu-24.04 grep -E '(vscode|ubuntu)' /etc/passwd
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
vscode:x:1001:1001::/home/vscode:/bin/bash

$ docker run -it --rm mcr.microsoft.com/devcontainers/base:ubuntu-22.04 grep -E '(vscode|ubuntu)' /etc/passwd
vscode:x:1000:1000::/home/vscode:/bin/bash

Workaround

I added this to my Dockerfile right after the FROM line:

RUN userdel -r ubuntu || true

Now rebuilding and launching the image works as expected.

@MawKKe
Copy link
Author

MawKKe commented May 10, 2024

It seems the devcontainer images are based on these https://hub.docker.com/_/buildpack-deps/ which themselves are based on the official ubuntu images https://hub.docker.com/_/ubuntu

Apparently the extra user originates from there:

$ docker run -it --rm ubuntu:22.04 grep 'ubuntu' /etc/passwd || echo nothing
nothing
$ docker run -it --rm ubuntu:24.04 grep 'ubuntu' /etc/passwd || echo nothing
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash

@samruddhikhandale
Copy link
Member

Hi 👋

It seems the devcontainer images are based on these https://hub.docker.com/_/buildpack-deps/ which themselves are based on the official ubuntu images https://hub.docker.com/_/ubuntu

Yes, that's correct! With the newer release of noble, the official ubuntu image added a new ubuntu user with gid/uid:1000. This started conflicting with with vscode:1000.

Hence, we decided to let vscode's UID/GID update as we didn't want to update (rename/delete/update) the ubuntu user provided by the base image.

This is not the case with focal and jammy, hence the vscode:1000 is intact.

#1036 mentions the same thing in the description!

@MawKKe
Copy link
Author

MawKKe commented May 10, 2024

So is the image supposed to work with UID 1001 just as before? For now it is not, not at least for me.

(Of course it is possible that there is something unrelated going on with my setup)

@schlegel11
Copy link

schlegel11 commented May 13, 2024

I have the exact same problem 😉
I can see that merge #1036 fixes the overall image build issue but not the issue that a mapping to the host system is currently done with a wrong uid or at least wrong for the default user's uid for most of us.

@fnkr
Copy link

fnkr commented Jun 11, 2024

Adding this to my Dockerfile to fix it:

# Using mcr.microsoft.com/devcontainers/base:ubuntu-24.04 as base image
RUN userdel -r ubuntu; usermod -u 1000 vscode; groupmod -g 1000 vscode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants