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

Add support for --chown flag to COPY command #9

Closed
priyawadhwa opened this issue Feb 15, 2018 · 9 comments · Fixed by #962
Closed

Add support for --chown flag to COPY command #9

priyawadhwa opened this issue Feb 15, 2018 · 9 comments · Fixed by #962
Labels
area/dockerfile-command For all bugs related to dockerfile file commands area/multi-stage builds issues related to kaniko multi-stage builds help wanted Looking for a volunteer! kind/feature-request

Comments

@priyawadhwa
Copy link
Collaborator

See #1 for details

@priyawadhwa priyawadhwa added the area/multi-stage builds issues related to kaniko multi-stage builds label Feb 28, 2018
@priyawadhwa priyawadhwa changed the title Add support for --chown and --from flags to COPY command Add support for --chown flag to COPY command May 17, 2018
@pmcq
Copy link

pmcq commented Jul 13, 2018

Hi I'm interested in getting this issue resolved for multi-stage builds we are working on, but don't have experience contributing to a go repo. I'd like to help out if possible though (at least for some of the --chown syntax)

pmcq added a commit to algorithmiaio/langpacks that referenced this issue Jul 13, 2018
@priyawadhwa
Copy link
Collaborator Author

Hey @pmcq , thanks for your interest. I've outlined a few steps you might want to take to add this feature

  1. In copy.go, in Execute, you'll first want to get uid/gid from c.cmd.Chown, which is a string. We do something similar for the USER command here, so you might be able to move some of that logic into a separate function which both COPY and USER could call.
  2. In the copy command we call util.CopyDir and util.CopyFile. You'll need to change the signatures of these functions here and here to take in the uid/gid, and apply it to every file that's copied over in those functions.
  3. You can run our unit tests by running make test (you'll have to update some of them since I think we use CopyFile and CopyDir in a few different places).

Let me know if you have any more questions.

@pmcq
Copy link

pmcq commented Jul 17, 2018

I made changes in a fork here: https://github.com/GoogleContainerTools/kaniko/compare/master...pmcq:copy-chown?expand=1 and built an image and used it to run dockerfiles with COPY --chown flag succesfully. All existing unit tests pass, however I don't see any existing tests on util.CopyDir/CopyFile or CopySymlink that need modification.

I was thinking of creating new tests that just copy file/dir/symlink but since the user running the testcases isn't going to be a root user, it wouldn't be allowed to chown the file to someone else, so the testcase wouldn't add anything specific checks for this change. Should I open a PR or is there a different type of testing you would like?

@priyawadhwa
Copy link
Collaborator Author

@pmcq thanks for opening a PR!

@swistaczek
Copy link

Hey, this is still an active issue. PR #250 is closed and abandoned.

@ataillefer
Copy link

Hi, any news on this?

It's really problematic when using multi-stage to not be able to use COPY and change the owner of the copied directory.

Of course, a workaround is to call an extra RUN chown -R uid:gid mydir after the COPY instruction, but it adds a layer of the size of the copied directory, so directly impacts the final image size...

Thanks

@fredr
Copy link

fredr commented Nov 5, 2019

@ataillefer beware, that walkaround has some unexpected problems of its own, see #845

@cvgw cvgw added the area/dockerfile-command For all bugs related to dockerfile file commands label Dec 23, 2019
@wstrange
Copy link

wstrange commented Jan 9, 2020

Any updates on this issue?

@diclophis
Copy link

I just ran into this bug as well...

xanonid added a commit to xanonid/kaniko that referenced this issue Jan 10, 2020
@xanonid xanonid mentioned this issue Jan 10, 2020
4 tasks
xanonid added a commit to xanonid/kaniko that referenced this issue Jan 10, 2020
WanzenBug pushed a commit to WanzenBug/kaniko that referenced this issue Jan 22, 2020
xanonid added a commit to xanonid/kaniko that referenced this issue Jan 24, 2020
tejal29 pushed a commit to xanonid/kaniko that referenced this issue Jan 31, 2020
tejal29 pushed a commit to xanonid/kaniko that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands area/multi-stage builds issues related to kaniko multi-stage builds help wanted Looking for a volunteer! kind/feature-request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants