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

groups: cannot find name for group ID XYZ #2327

Closed
gadiego92 opened this issue Nov 23, 2022 · 1 comment · Fixed by #2689
Closed

groups: cannot find name for group ID XYZ #2327

gadiego92 opened this issue Nov 23, 2022 · 1 comment · Fixed by #2689
Labels
area/uid kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next. regression/v1.8.0 regression

Comments

@gadiego92
Copy link
Contributor

Hi, I think I'm facing some issue in the latest releases. My issue is with groups command.

When I run the groups command in a Dockerfile I get the error:

groups: cannot find name for group ID XYZ

Let's use the following Dockerfile to see the behavior:

FROM ubuntu

RUN groupadd -g 1234 group123

RUN useradd -u 54321 -g 1234 user123

USER user123

RUN groups

Actual behavior
In the releases 1.9.0 (8cab37f84a44) and 1.9.1 (dcfa90c317b5) this is the output when I run the executor command with the previous Dockerfile:

/workspace # executor --dockerfile "Dockerfile" --no-push
INFO[0000] Retrieving image manifest ubuntu
INFO[0000] Retrieving image ubuntu from registry index.docker.io
INFO[0001] Built cross stage deps: map[]
INFO[0001] Retrieving image manifest ubuntu
INFO[0001] Returning cached image manifest
INFO[0001] Executing 0 build triggers
INFO[0001] Building stage 'ubuntu' [idx: '0', base-idx: '-1']
INFO[0001] Unpacking rootfs as cmd RUN groupadd -g 1234 group123 requires it.
INFO[0002] RUN groupadd -g 1234 group123
INFO[0002] Initializing snapshotter ...
INFO[0002] Taking snapshot of full filesystem...
INFO[0003] Cmd: /bin/sh
INFO[0003] Args: [-c groupadd -g 1234 group123]
INFO[0003] Running: [/bin/sh -c groupadd -g 1234 group123]
INFO[0003] Taking snapshot of full filesystem...
INFO[0003] RUN useradd -u 54321 -g 1234 user123
INFO[0003] Cmd: /bin/sh
INFO[0003] Args: [-c useradd -u 54321 -g 1234 user123]
INFO[0003] Running: [/bin/sh -c useradd -u 54321 -g 1234 user123]
INFO[0003] Taking snapshot of full filesystem...
INFO[0003] USER user123
INFO[0003] Cmd: USER
INFO[0003] RUN groups
INFO[0003] Cmd: /bin/sh
INFO[0003] Args: [-c groups]
INFO[0003] Util.Lookup returned: &{Uid:54321 Gid:1234 Username:user123 Name: HomeDir:/home/user123}
INFO[0003] Performing slow lookup of group ids for user123
INFO[0003] Running: [/bin/sh -c groups]
groups: cannot find name for group ID 54321
54321 group123
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1

Expected behavior
In the releases 1.8.1 (e1e8f684a8d2) and the previous ones, the behavior is the following:

/workspace # executor --dockerfile "Dockerfile" --no-push
INFO[0000] Retrieving image manifest ubuntu
INFO[0000] Retrieving image ubuntu from registry index.docker.io
INFO[0001] Built cross stage deps: map[]
INFO[0001] Retrieving image manifest ubuntu
INFO[0001] Returning cached image manifest
INFO[0001] Executing 0 build triggers
INFO[0001] Unpacking rootfs as cmd RUN groupadd -g 1234 group123 requires it.
INFO[0002] RUN groupadd -g 1234 group123
INFO[0002] Taking snapshot of full filesystem...
INFO[0003] cmd: /bin/sh
INFO[0003] args: [-c groupadd -g 1234 group123]
INFO[0003] Running: [/bin/sh -c groupadd -g 1234 group123]
INFO[0003] Taking snapshot of full filesystem...
INFO[0003] RUN useradd -u 54321 -g 1234 user123
INFO[0003] cmd: /bin/sh
INFO[0003] args: [-c useradd -u 54321 -g 1234 user123]
INFO[0003] Running: [/bin/sh -c useradd -u 54321 -g 1234 user123]
INFO[0003] Taking snapshot of full filesystem...
INFO[0003] USER user123
INFO[0003] cmd: USER
INFO[0003] RUN groups
INFO[0003] cmd: /bin/sh
INFO[0003] args: [-c groups]
INFO[0003] util.Lookup returned: &{Uid:54321 Gid:1234 Username:user123 Name: HomeDir:/home/user123}
INFO[0003] performing slow lookup of group ids for user123
INFO[0003] Running: [/bin/sh -c groups]
group123
INFO[0003] Taking snapshot of full filesystem...
INFO[0003] No files were changed, appending empty layer to config. No layer added to image.
INFO[0003] Skipping push to container registry due to --no-push flag

Additional Information
I have done some testing and I would say the issue is in the commit: aad03dc

I built Kaniko images locally without that commit (aad03dc) and it seems it worked fine. That's why I think there is an issue in the mentioned commit.

@aaron-prindle aaron-prindle added regression priority/p1 Basic need feature compatibility with docker build. we should be working on this next. area/uid kind/bug Something isn't working labels May 31, 2023
@gadiego92
Copy link
Contributor Author

gadiego92 commented Aug 19, 2023

It looks like Kaniko thinks by default that the UID (54321 in the example) is also a GID.
So when it tries to resolve the GIDs it cannot find 54321 because indeed it is not a GID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/uid kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next. regression/v1.8.0 regression
Projects
None yet
2 participants