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

dockerfile: Support --chmod with non-octal notation, such as --chmod=g=u #1951

Closed
thernstig opened this issue Jan 21, 2021 · 3 comments · Fixed by #5380
Closed

dockerfile: Support --chmod with non-octal notation, such as --chmod=g=u #1951

thernstig opened this issue Jan 21, 2021 · 3 comments · Fixed by #5380

Comments

@thernstig
Copy link

#1492 added support for e.g. --chmod=744 during a COPY command. Here is the original issue for supporting octal notation moby/moby#34819. However, in many situations this is insufficient.

For example, g=u is a way to chmod so that the group gets the same permissions as the user like so: chmod -R g=u dir. This would equal:

COPY --chmod=g=u --from=builder /server/ /server/

This is for example important in OpenShift.

@tobia also added some very valid argumentation for this: moby/moby#34819 (comment):

The usefulness of alpha syntax usually comes from the capital X permission, which means "executable only if the file was previously executable or if it is a directory."

This is because a recursive COPY with --chmod=644 would make all directories non-executable, meaning non-traversable; while a --chmod=755 would make all files executable. Both are inappropriate therefore unuseable 99% of the time.

A recursive COPY with --chmod=u=rwX,go=rX (capital Xes) would set directories to 755 and files to 644, unless a given file already had the executable bit in the source filesystem, in which case it would get 755.

It would be very nice if this support could be added!

@tonistiigi tonistiigi changed the title Feature: Support --chmod with with non-octal notation, such as --chmod=g=u dockerfile: Support --chmod with with non-octal notation, such as --chmod=g=u Jan 22, 2021
@manuschillerdev
Copy link

As I currently need this feature I'd love to implement it, if someone can give me a little guidance on it?

@rafrafek
Copy link

--umask would be nice too, see comment:
moby/moby#34819 (comment)

@thernstig thernstig changed the title dockerfile: Support --chmod with with non-octal notation, such as --chmod=g=u dockerfile: Support --chmod with with non-octal notation, such as --chmod=g=u Dec 3, 2023
@thernstig thernstig changed the title dockerfile: Support --chmod with with non-octal notation, such as --chmod=g=u dockerfile: Support --chmod with non-octal notation, such as --chmod=g=u May 3, 2024
@Clovel
Copy link

Clovel commented Aug 22, 2024

I'd love to see this implemented, as I need it too !

The usefulness of alpha syntax usually comes from the capital X permission, which means "executable only if the file was previously executable or if it is a directory."

This is because a recursive COPY with --chmod=644 would make all directories non-executable, meaning non-traversable; while a --chmod=755 would make all files executable. Both are inappropriate therefore unuseable 99% of the time.

A recursive COPY with --chmod=u=rwX,go=rX (capital Xes) would set directories to 755 and files to 644, unless a given file already had the executable bit in the source filesystem, in which case it would get 755.

The capital X is the reason I would like symbolic permissions to be supported. Aslo the g=u syntax.

Any news on this ?

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

Successfully merging a pull request may close this issue.

7 participants