-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 --link
incompatibility with COPY --chown
+ Both flags undocumented effect on existing destination path parents
#20660
Labels
area/build
Relates to Dockerfiles or docker build command
lifecycle/stale
status/triage
Needs triage
Comments
This was referenced Aug 21, 2024
Open
travisaustin
pushed a commit
to travisaustin/laravel-octane-dockerfile
that referenced
this issue
Nov 26, 2024
When building multi-architecture images with buildx, named user identifiers cannot be supplied to --chown if --link is used. This commit changes the `COPY --link --chown=....` lines to use the numeric user id instead of the named user. Instead of calling `COPY --link --chown=octane:octane`, it will call `COPY --link --chown=1000:1000`. This change will allow builds to succeed even when using buildx. See: docker/buildx#1526 docker/docs#20660 docker/buildx#1526 (comment)
This was referenced Nov 26, 2024
travisaustin
pushed a commit
to travisaustin/laravel-octane-dockerfile
that referenced
this issue
Nov 26, 2024
commit 07932f6 Author: Travis Austin <[email protected]> Date: Tue Nov 26 06:06:03 2024 -0800 Use numeric user and group in chown When building multi-architecture images with buildx, named user identifiers cannot be supplied to --chown if --link is used. This commit changes the `COPY --link --chown=....` lines to use the numeric user id instead of the named user. Instead of calling `COPY --link --chown=octane:octane`, it will call `COPY --link --chown=1000:1000`. This change will allow builds to succeed even when using buildx. See: docker/buildx#1526 docker/docs#20660 docker/buildx#1526 (comment)
smortexa
pushed a commit
to exaco/laravel-octane-dockerfile
that referenced
this issue
Nov 26, 2024
* Use numeric user and group in chown When building multi-architecture images with buildx, named user identifiers cannot be supplied to --chown if --link is used. This commit changes the `COPY --link --chown=....` lines to use the numeric user id instead of the named user. Instead of calling `COPY --link --chown=octane:octane`, it will call `COPY --link --chown=1000:1000`. This change will allow builds to succeed even when using buildx. See: docker/buildx#1526 docker/docs#20660 docker/buildx#1526 (comment) * Fixed incorrectly named variables in 1 Dockerfile --------- Co-authored-by: Travis Austin <[email protected]>
There hasn't been any activity on this issue for a long time. Prevent issues from auto-closing with a /lifecycle stale |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/build
Relates to Dockerfiles or docker build command
lifecycle/stale
status/triage
Needs triage
Is this a docs issue?
Type of issue
I can't find what I'm looking for
Description
Actionables:
COPY --chown
+COPY --link
should document their effect on modifying the permissions of any existing directories of the destination path provided.--chmod
does not behave in this manner which only adds to confusion.COPY --chown
docs mention default ownership of the copied source content is0:0
(regardless of--link
):--from
flag (without a--chown
override) to specify a different stage or image where theCOPY
source content ownership is preserved. This is demonstrated here with a visual + reproduction. As opposed toCOPY
with git and local contexts (instead of via--from
), where the original ownership is not preserved (becomes0:0
in container).COPY
target path that will use the fallback0:0 755
. However... if those parent dirs did already exist and--link
is used, their ownership and permission will also be replaced by0:0 755
(the implicitFROM scratch
that--link
introduces for it's rebase layer causes that).COPY
source content permissions are preserved (regardless of--link
), unless intentionally overriding with--chmod
.0.13.2
introduced777
(dir) +666
(file) permissions for checkout via git context when no umask was applied?, fixed in BuildKit0.15.2
(PR). Not applicable to the local build context.COPY --chown
with non-numeric values section should highlight awareness ofCOPY --link
being a common case for the vague build error it outputs:docker
driver, where it'll instead silently fail and fallback to0
.mode=
(the--chmod
equivalent) forRUN --mount=type=cache ...
has two known quirks to consider documenting:mode=
option will persist a cache mount across builds with--no-cache
(which would normally discard the cache).uid
andgid
options). Line identified from here.docker buildx build --builder docker ...
(default fordocker build ...
) prior to BuildKit0.15.2
will apply022
umask to a configuredmode=
value of the cachetarget=
(mode=773
sets751
on the target dir). Yet does not apply todocker-container
driver running BuildKit prior to0.15.2
.Full report details
COPY --link
does not describe it's affect on parent directories where the permissions and ownership are modified to755 0:0
.Perhaps because this seems to be specific to the
docker buildx build --builder ...
driver used, at least withdocker-container
it occurs while it does not with thedocker
driver. The behaviour also differs in the context of--chmod
and--chown
usage with--link
.More information about this inconsistency here:
COPY --link --chown
unexpectedly changes parent dir ownership buildx#1855 (comment)The docs do not indicate how to verify
--link
is being used.--link=false
?0.10.0
theCOPY --link
feature would not raise an error and silently fallback to--link=false
.It would be good for the docs to at least clarify the
--link
scenario that may result in unexpected permissions/ownership changes to parent dirs of the target path. And if the--chmod=null
workaround has any relevant concerns before that potentially spreads in adoption.In the context of
--link --chown=invalid
, this is hinted at in the docs:However, as has been seen in various reports regarding these two features.. it's often not understood that
--link
is the cause when a build outputs this unhelpful error message. Some projects respond to this by removing--link
, or finding a way to ensure the UID/GID values are deterministic.That section should be amended to cite the common case with
--link
?Potentially relevant context:
COPY --link
not compatible withchown
moby/buildkit#2987 (comment)umask 022
(mode
adjusting permissions affects cache mount persistence), has some relevance toCOPY
but maybe not--link
?)Location
https://docs.docker.com/reference/dockerfile/#copy
Suggestion
Suggestions above under Actionables.
RUN
.Usually the doc issues I engage with here become stale and locked by the docker bot, never to be addressed. Thus the above is serves as an informal documentation reference if that occurs.
Some of the observed behaviour may be bugs that will get addressed. Docs could be delayed, but note that some of these concerns have been known for well over a year, if that continues it may be better to document the caveat for the benefit of users.
The text was updated successfully, but these errors were encountered: