-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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 option -L
to allow docker cp
follow symbol link
#16613
Conversation
|
7344988
to
8f84705
Compare
Removing a whole test without adding a new one makes me quite uncomfortable. I'd like to know what @jlhawn thinks about this change before giving it my 👍 |
@calavera Understand, that test case is wholly removed because it's totally inappropriate. |
@calavera |
Like pointed out in #16555 More importantly, there is an API for pulling and pushing files to/from containers and there is a cli tool. IMHO if we allow following of the source we should do it in the client side and not change API. This is also how we do it currently when you copy local files into a symlink inside a container. We resolve the actual target directory in the client side and start upload to that. |
@tonistiigi What do you think of extra option of |
@WeiZhang555 I'm not sure if its better to add |
@tonistiigi But it's also OK to change client only if you really feel uncomfortable with API change, I can take a look at what I can do for that. |
@WeiZhang555 I think the current API has the correct behavior. |
@tonistiigi All right, I can try to find a way to make client-only change, maybe need a couple of days. :) |
8f84705
to
1747fc5
Compare
Just refreshed my PR, add one '-L' option to allow following symbol links. Let's see how it works. |
4815599
to
3871588
Compare
docker cp
can't follow symbol link-L
to allow docker cp
follow symbol link
3871588
to
3aca000
Compare
@tonistiigi @calavera @jlhawn One more thing, the reason why I use the Let me know whether this is acceptable for you in case I write too many codes that will never be merged. :) |
@WeiZhang555 I didn't look at the code too carefully atm but the approach looks good to me. Tests look good as well but yes, inctegration-cli and docs are also needed. I wonder if |
func TestCopyCaseC(t *testing.T) { | ||
// C.1 SRC specifies a file and DST exists as a file. This should overwrite | ||
// the file at DST with the contents of the source file. | ||
func TestCopyCaseC1(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use TestCopyCaseCFollowSymlink
or TestCopyCaseCFSym
instead the 1/2
suffix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can fix this.
3aca000
to
352c4c4
Compare
@tonistiigi We can find a nice option together, but I'll go on adding the integration testa and docs, also more tests to see if this change works correctly. :) |
ed655e7
to
2b152cb
Compare
@tonistiigi updated, please help review :) |
@WeiZhang555 sorry, needs a rebase 😓 |
2b152cb
to
58e77ac
Compare
a tar archive to `STDOUT` if `-` is specified). | ||
The `docker cp` utility copies the contents of `SRC_PATH` to the `DEST_PATH`. | ||
You can copy from the container's file system to the local machine or the | ||
reverse, from the local filesystem to the container. if If `-` is specified for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double "if" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are right! 👍
Thanks @WeiZhang555, I added my comments inline |
@thaJeztah Very detailed suggestion, I'll do it now 👍 |
9919b66
to
6cb2b2b
Compare
@thaJeztah @moxiegirl updated.
I think it's not very accurate. How about
Maybe this is better? WDYT? |
Hm, yes, I think that makes sense |
Fixes moby#16555 Original docker `cp` always copy symbol link itself instead of target, now we provide '-L' option to allow docker to follow symbol link to real target. Signed-off-by: Zhang Wei <[email protected]>
6cb2b2b
to
92600bd
Compare
@thaJeztah updated. 😄 |
LGTM! Thank you @WeiZhang555 :-D |
Thanks @WeiZhang555 for your contribution! LGTM |
restarting Windows build |
Windows builds are definitely in holidays.. 😅 |
Add option `-L` to allow `docker cp` follow symbol link
Yeah, Windows build is a naughty boy 😄 Thank you all for helping! 😆 |
fixes #16555
When user try to cp a symbol link to/from a container, what the user
really want is to copy the link target but not the symbol link, as the
symbol link is only valid and useful in host/container's scope.
All in all, who will need a symbol link copied to container which points
to some file on host? That's meaningless.
And this is also the default behavior of a unix
cp
command.Signed-off-by: Zhang Wei [email protected]