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 and ADD don't add as the current user #7390
Comments
Looking through the builder code ( |
As per the documentation at https://docs.docker.com/reference/builder/ the behaviour of COPY and ADD commands is as follows : "All new files and directories are created with a UID and GID of 0." The USER command behaviour is as follows (as per doc): "The USER instruction sets the user name or UID to use when running the image and for any following RUN directives." So ideally the RUN command should use the new username, but it seems that eventually all files/directories are Chowned to root. |
@vivekdasgupta I understand that it is documented like that, my proposal deals entirely with the consistency of the interface. If the EDIT: Whoops. Didn't realise that this was the seminal issue. My proposal for a fix is here: #7537. |
Closing as dup of #6119 |
While the
USER
directive will change the current user, the owner of all files injected into a container using theCOPY
andADD
directives are always root (even if you set the user to any other user) while all other instructions will run as the specified user.Here's an example Dockerfile:
Is this meant to happen?
The text was updated successfully, but these errors were encountered: