Add --chown flag to Dockerfile ADD and COPY#28499
Add --chown flag to Dockerfile ADD and COPY#28499duglin wants to merge 2 commits intomoby:masterfrom
Conversation
daemon/oci_windows.go
Outdated
There was a problem hiding this comment.
I understand this solves duplication layer when changing owner, but it does not solve layer duplication needed for chmod +x (which is in my case needed on 60% of COPY/ADD in most images) ?
|
/cc @thaJeztah I've seen you create similar issues and provide feedback, maybe you can help cc in the right people to get this merged ? |
|
Let's move this to code review |
|
If |
|
did someone suggest a chmod option? I missed that |
|
It's been discussed a few times for similar reasons to wanting to control
the user, and there's a comment on this PR asking about it specifically.
:smile:
#28499 (comment)
|
|
doi - sorry I missed that. I was scanning too quickly. |
bb9a873 to
9291fea
Compare
|
I need ADD extension to use instead of: Thus without +x option ADD is useless anyway (if I already have run... I put there also non-executables so will not use COPY/ADD even for --user option). |
|
+1 |
b8790bf to
beee26d
Compare
|
@tianon which would be better: The 2nd feels a little like we're trying to expose our implementation detail (changing things after the fact vs setting the properties on the files during creation) - when the end user should just care about the properties having the right values regardless of how they are set. |
|
Hmm, good point, but In my mind, the argument for |
|
i'm also proposing
these would rise the
or more clearer directives for different kinds: |
|
@glensc could you open a separate issue for that proposal? Also, would be worth describing how it should interact with different commands that take options (just for illustration, if |
|
@tianon ok - will go with I'd prefer to leave I have a high-order question for people.... if we were developing To be clear, the thoughts? |
|
I've copied my comments to moby/buildkit#4242. |
|
This still isn't in the docs. Is it used like this? COPY from.txt /to.txt --chown someuser |
|
@jazoom This is not merged. |
|
Looking for the solution for ages. Subscribed |
| b.runConfig.Cmd = strslice.StrSlice(append(getShell(b.runConfig), fmt.Sprintf("#(nop) %s --chown=%s %s in %s ", cmdName, usergrp, srcHash, dest))) | ||
| } else { | ||
| b.runConfig.Cmd = strslice.StrSlice(append(getShell(b.runConfig), fmt.Sprintf("#(nop) %s %s in %s ", cmdName, srcHash, dest))) | ||
| } |
There was a problem hiding this comment.
These two branches are nearly identical. Could you move most of this line out of the branch, and leave only the inner most fmt.Sprintf() in the branch?
| comment = fmt.Sprintf("%s --chown=%s %s in %s", cmdName, usergrp, origPaths, dest) | ||
| } else { | ||
| comment = fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest) | ||
| } |
There was a problem hiding this comment.
This looks awfully similar to the branch above (that I commented on).
How about a function for this? The #(nop) prefix could be an arg.
| // uid:gid, username:gid, or uid:groupname and parses the passwd file in the container | ||
| // to return the ExecUser referred to by `username`. | ||
| func (container *Container) ParseUserGrp(username string) (*user.ExecUser, error) { | ||
| passwdPath, err := user.GetPasswdPath() |
There was a problem hiding this comment.
I believe this call always returns an err on windows, which means this new flag would not work for the windows builder.
Are we ok with that?
|
Needs a rebase as well |
|
@duglin Thanks for working on this! It seems this PR hasn't seen any activity in 4 weeks. I'm going to close the PR since there is no activity. If/when you have time to rebase, and respond to the comments please feel free to re-open it (or ping me and I can). |
|
Ok, let's reopen once the discussion in #30110 has produced some results |
|
I'm unsure how #32816 is blocking this issue. To some extent, they seem unrelated as the problem of 32816 is related to the source, right? This PR seems so helpful it hurts to see it goes by closed for another week. |
|
reopening (again) following #30110 (comment), but probably needs a bit of rewriting |
|
(make that a lot of rewriting LOL) |
|
I can carry this if that's helpful to @duglin? |
|
go for it! thanks @estesp |
|
Carried in #34263 |
Carrying #27303 since Kara is off doing other exciting things.
What Kara did
Add a --chown flag to Dockerfile ADD and COPY instructions, proposed by Proposal: Implement --user flag for COPY and ADD #13600
How Kara did it
Added flag to add and disptachCopy of builder/dockerfile/dispatchers.go, and passed the relevant information through to the daemon which looks up the user/group using a new function on the container object.
How to verify it
Create a Dockerfile that uses the --chown flag on an ADD or COPY instruction, and check that the file is listed as having the appropriate owner
Description for the changelog
add --chown flag to Dockerfile ADD and COPY instructions
2nd commit is just a rebase.
Signed-off-by: Doug Davis dug@us.ibm.com