-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
COPY command changes the directory permissions to change. #3602
Comments
Thanks for reporting. I think this may be a combination of things, and I think some of this was discussed on #2414 (comment);
While that may explain what's happening, I agree this is somewhat confusing, and it definitely feels unexpected that the permissions change. So, if the above is the reason, I wonder what the options are for this 🤔; One option would be to copy the directory permissions of the parent layer However, this could potentially defeat the purpose of Effectively, this would be making |
@jedevc @tonistiigi @crazy-max PTAL (should this be moved to the BuildKit issue tracker?) |
BuildKit 0.11.2 FROM alpine AS base
RUN apk add --no-cache tree
RUN tree -apufi /tmp
COPY foo.txt /tmp/foo.txt
RUN tree -apufi /tmp
COPY --link foo.txt /tmp/foo.txt
RUN tree -apufi /tmp
Yes please |
I transferred the ticket to the BuildKit issue tracker 👍 |
As @thaJeztah wrote, You can read the background of this at #2414 . It is possible that in some future release, we can improve this a bit by removing the parent directory record from the layer tarball when we create the image, but there will always be specific cases (symlinks, chown etc) where doing a linked copy requires these extra precaucions. |
This code used to function properly in previous Docker engine versions, is there any reason why it suddenly failed in the latest update? |
I wonder (but @tonistiigi may be able to confirm) if that's where these come into play;
If the |
Dockerfiles that opt-in to |
Oh! Good one, I assumed it depended on the Dockerfile frontend, but didn't consider the option would be previously silently ignored. I guess it no longer helps for this specific case (now that 23.0 is out), but do you know if warnings are still planned for cases like this? (Dockerfile uses option that's not supported by a specific version of BuildKit) also see #1952 (comment) |
I also encounter some unexpected directory permission changes using 23.0.0 with moby worker in buildkit. Instead of using COPY op, what i did is |
@Kaiyang-Chen perhaps default umask ( |
@thaJeztah In your previous reply, version before 23.0.0 used 0777 for undefined directory, and after it there will be a default umask apply to it? It seems for version before 23.0.0, the directory permission is indeed 0777 using container-based buildkit in above implementation, but when using moby worker, the permission are changed to 0755. Are there any difference between built-in moby worker from buildx and container-based buildkit in such behavious? What's more, in my case, when creating the directory, i explicitly set the permission to 0777, why there is still umask apply to it? Thanks for your help! |
Are you sure the directory didn't exist before? Mkdir does not overwrite perms for existing directories. The umask should not apply. If it does, then it is a bug. The last issue is completely different from the initial report. If you have some reproducers for it, then create a new issue with all info. |
The |
Someone reported a similar issue but without |
This does not matter. Link is equivalent to:
|
Has the findings below with I notice you mentioned permissions specifically, was that also applicable to ownership expectations with
What about when From this reference we have this minimal example:
Ownership and permissions of the
If the
Observations:
Seems like this inconsistency is a bug? (UPDATE: Full overview documented here)
Does the |
Description
In the latest v23.0.0 update, I found that using
COPY --link FILE.txt /tmp/FILE.txt
caused the permissions of the/tmp
directory to change from 777 to 755. This caused problems downstream becauseapt
no longer had write permissions to the/tmp
directory. Though this can be fixed by changing the directory that the file was copied to, this is obviously a bug.Reproduce
git clone https://github.com/cresset-template/cresset.git cd cresset git checkout 2fc0889 make env make build
Expected behavior
I tried adding
RUN ls -alh /tmp
to the Dockerfile before and after theCOPY
command in line 418 of the Cresset Dockerfile and the file permissions that I found were different. TheCOPY
command should not change the permissions of the directory.docker version
Client: Docker Engine - Community Version: 23.0.0 API version: 1.42 Go version: go1.19.5 Git commit: e92dd87 Built: Wed Feb 1 17:49:08 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 23.0.0 API version: 1.42 (minimum version 1.12) Go version: go1.19.5 Git commit: d7573ab Built: Wed Feb 1 17:49:08 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.16 GitCommit: 31aa4358a36870b21a992d3ad2bef29e1d693bec runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
Before
COPY
:After
COPY
:The text was updated successfully, but these errors were encountered: