Skip to content

Make container.Copy support volumes#8509

Merged
LK4D4 merged 1 commit intomoby:masterfrom
cpuguy83:make_copy_support_volumes
Oct 21, 2014
Merged

Make container.Copy support volumes#8509
LK4D4 merged 1 commit intomoby:masterfrom
cpuguy83:make_copy_support_volumes

Conversation

@cpuguy83
Copy link
Member

Fixes #1992

Right now when you docker cp a path which is in a volume, the cp
itself works, however you end up getting files that are in the
container's fs rather than the files in the volume (which is not in the
container's fs).
This makes it so when you docker cp a path that is in a volume it
follows the volume to the real path on the host.

archive.go has been modified so that when you do docker cp mydata:/foo ., and /foo is the volume, the outputed folder is called "foo" instead
of the volume ID (because we are telling it to tar up
/var/lib/docker/vfs/dir/<some id> and not "foo", but the user would be
expecting "foo", not the ID

@tiborvass
Copy link
Contributor

@cpuguy83 ❤️

@cpuguy83 cpuguy83 force-pushed the make_copy_support_volumes branch from edeee39 to cb66e9f Compare October 11, 2014 02:48
@nathanleclaire
Copy link
Contributor

❤️

@bfirsh
Copy link
Contributor

bfirsh commented Oct 17, 2014

❤️

@LK4D4
Copy link
Contributor

LK4D4 commented Oct 17, 2014

Also, I want to say that container.Copy is awful name for this method. Anyway patch is great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change. This variable used only in TarWithOptions and without this change I saw that this is just Compression and Includes, now I need to look all code between this line and TarWithOptions to be sure that there is no other things in opts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, I originally had this implemented differently and needed it moved up (or rather wanted it), but don't need to anymore.

I'll fix.

@cpuguy83 cpuguy83 force-pushed the make_copy_support_volumes branch from 12290e2 to e4b9f25 Compare October 17, 2014 20:18
@cpuguy83
Copy link
Member Author

@LK4D4 Updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check the length here? what if its 0, I know it shouldn't ever be buttt...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length of? resource?
In a way it is checking because the length of the mountToPath couldn't be 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok as long as mountToPath could never be 0, bc of the slice I was just worried about a panic :) but good to know

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it may be worth it to check just in case.

@jessfraz
Copy link
Contributor

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking the length of MountToPath here then would suffice sense it gets passed to Export

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@cpuguy83 cpuguy83 force-pushed the make_copy_support_volumes branch from e4b9f25 to d0a50df Compare October 17, 2014 20:59
@jessfraz
Copy link
Contributor

👍

@cpuguy83 cpuguy83 force-pushed the make_copy_support_volumes branch from d0a50df to 36102c1 Compare October 21, 2014 00:17
Fixes moby#1992

Right now when you `docker cp` a path which is in a volume, the cp
itself works, however you end up getting files that are in the
container's fs rather than the files in the volume (which is not in the
container's fs).
This makes it so when you `docker cp` a path that is in a volume it
follows the volume to the real path on the host.

archive.go has been modified so that when you do `docker cp mydata:/foo
.`, and /foo is the volume, the outputed folder is called "foo" instead
of the volume ID (because we are telling it to tar up
`/var/lib/docker/vfs/dir/<some id>` and not "foo", but the user would be
expecting "foo", not the ID

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the make_copy_support_volumes branch from 36102c1 to ef98fe0 Compare October 21, 2014 00:23
@LK4D4
Copy link
Contributor

LK4D4 commented Oct 21, 2014

Commit message helped a lot.
LGTM

LK4D4 added a commit that referenced this pull request Oct 21, 2014
@LK4D4 LK4D4 merged commit a0781f3 into moby:master Oct 21, 2014
@SvenDowideit
Copy link
Contributor

OI!

Where's the documentation for this change?

@thaJeztah
Copy link
Member

@SvenDowideit docs were probably copied from a volume using the previous build? 😉

cpuguy83 added a commit to cpuguy83/docker that referenced this pull request Nov 10, 2014
SvenDowideit added a commit that referenced this pull request Nov 11, 2014
yoheiueda pushed a commit to yoheiueda/docker that referenced this pull request Nov 21, 2014
@bjaglin bjaglin mentioned this pull request Nov 27, 2014
jameskyle added a commit to jameskyle/kubernetes that referenced this pull request Dec 1, 2014
This commit brings two main changes, notably:

Two new options that can be set as environment variables

- DOCKER_OPTS: any arbitrary set of docker options. Example: --tlsverify
- DOCKER_NATIVE: This forces the use of the native docker available.
                 This is most useful if you're on OS X and do not want
                 to use boot2docker.

Now uses 'docker cp' instead of tar piping to transfer files. This
currently must be done by copying the binaries off of the docker volume
and into a local filesystem (/tmp) before a docker cp is done. This
workaround will no longer be necessary after bug fix
moby/moby#8509 makes it into stable.

This was necessary because the tar | tar method was creating corrupted
archives on OS X even with the < /dev/null workaround.
@cpuguy83 cpuguy83 deleted the make_copy_support_volumes branch September 20, 2017 16:57
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

Successfully merging this pull request may close these issues.

docker cp should support VOLUMEs

8 participants