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

frontend/dockerfile/dockerignore: update main context dockerignore error #6

Conversation

jedevc
Copy link

@jedevc jedevc commented Jul 26, 2023

See moby#4062.

This brings the MainContext dockerignore error inline with the NamedContext dockerignore error, now printing the exact name of the file.

This brings the MainContext dockerignore error inline with the
NamedContext dockerignore error, now printing the exact name of the
file.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Copy link
Owner

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice, thank you!

@thaJeztah thaJeztah merged commit d0ce775 into thaJeztah:cleanup_dockerignore Jul 26, 2023
6 checks passed
thaJeztah added a commit that referenced this pull request May 17, 2024
I was trying to run a build stage as non-root user, but it uses some cache
mounts. So I tried to mount the cache-mount with a specific group (gid), and
set permissions to 0775 (instead of the default 0755) to allow the stage to
write, but it looks like it still ends up with 0755 permissions.

Most minimal reproducer;

    docker build --progress=plain --no-cache -<<'EOF'
    # syntax=docker/dockerfile:1

    FROM alpine
    RUN --mount=type=cache,target=/hello/.cache,mode=0775 ls -la /hello/.cache/

Which shows that the target has 0755 permissions;

    #6 [stage-0 1/2] FROM docker.io/library/alpine:latest
    #6 DONE 0.0s

    #7 [internal] settings cache mount permissions
    #7 DONE 0.1s

    #8 [stage-0 2/2] RUN --mount=type=cache,target=/hello/.cache,mode=0775  ls -la /hello/.cache/
    #8 0.641 total 8
    #8 0.641 drwxr-xr-x    2 root     root          4096 May 17 12:04 .
    #8 0.641 drwxr-xr-x    3 root     root          4096 May 17 12:04 ..
    #8 DONE 0.7s

Looking at that `settings cache mount permissions` message brings me to this
code, which uses `llb.Mkdir`;
https://github.com/moby/buildkit/blob/4b5bf7ef9b3cd0a2485c173f0700dce21e83d964/frontend/dockerfile/dockerfile2llb/convert_runmount.go#L60

My initial assumption is that possibly the given filemode still gets an umask
applied, causing the effective permissions to be different.

It's a bit hard to find where the actual `Mkdir` happens, because that function
returns a `FileOp` (which only contains the options), but looking through tests
I see that there's various tests setting a mode, but all of them seem to use
a mode that's not affected by umask (assuming default `022` umask); most (if
not "all") of them seem to be using (e.g.) `0700` or `0600`.

Let's change a test to see if it fails, which may confirm my suspicion.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants