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

Support copying files to a container with a given ownership #605

Open
cristianrgreco opened this issue Jul 13, 2023 · 3 comments
Open

Support copying files to a container with a given ownership #605

cristianrgreco opened this issue Jul 13, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Jul 13, 2023

The Docker API for copying an archive to a container has a flag CopyUIDGID.

You could therefore chown a file locally to whatever UID/GID required, and this ownership will be retained in the container. This simulates an equivalent of

COPY --chown=user:group myfile /path/in/container/myfile

# OR

COPY myfile /path/in/container/myfile
RUN chown user:group myfile
@cristianrgreco
Copy link
Collaborator Author

cristianrgreco commented Jul 13, 2023

@mutantcornholio Would something like this work for your use case? Specifically setting the UID/GID on the file locally to the desired UID/GID on the container?

@mutantcornholio
Copy link

Totally!

@cristianrgreco
Copy link
Collaborator Author

cristianrgreco commented Jul 14, 2023

Tracking this issue at the moment mafintosh/tar-fs#108. Setting the file ownership permissions manually and doing a docker cp into the container correctly preserves the permissions. From my testing it seems the tar-fs library is what's losing the ownership permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants