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

COPY command ignores USER, sets file ownership to root #2

Open
nunofgs opened this issue Sep 11, 2015 · 3 comments
Open

COPY command ignores USER, sets file ownership to root #2

nunofgs opened this issue Sep 11, 2015 · 3 comments

Comments

@nunofgs
Copy link

nunofgs commented Sep 11, 2015

There are multiple issues submitted to the docker/docker about this.

My use case is similar to:

FROM ubuntu
RUN adduser foo
USER foo
ADD . /foo

I believe the USER instruction should affect any subsequent COPY and ADD instructions to avoid having to always chown any copied directories/files.

Any chance dockramp could support this use case?

@jlhawn
Copy link
Owner

jlhawn commented Sep 22, 2015

dockramp could support this if the API endpoint did. I think it's a good behavior to have, but there still might be a desire to copy files with ownership other than the current USER value.

I was thinking of something that looks like:

COPY --chown="user:group" foo/bar /baz

It would allow you to specify ownership per-COPY. Again, it relies on the Docker API endpoint used by COPY to support this functionality.

@iambowen
Copy link

I think it's a pretty wired setting for not giving options to set the file ownership and permission.
Can we just make some improvement on this?

@Rishamdeep
Copy link

Rishamdeep commented Jul 14, 2022

This issue has been resolved.
Starting with Docker 17.09.0-ce (2017–09–26) ADD/COPY commands now support the --chown flag in Dockerfile:

Example of usage:
COPY --chown=docker:docker source /path/to/destination

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

No branches or pull requests

4 participants