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

docker cp? #2044

Closed
pauldotknopf opened this issue Jan 23, 2018 · 6 comments
Closed

docker cp? #2044

pauldotknopf opened this issue Jan 23, 2018 · 6 comments

Comments

@pauldotknopf
Copy link
Contributor

What is the state of downloading/uploading files to containers/snapshots?

Is there some way for the client to get the path to an active snapshot?

Maybe there is a way to create content blobs from an active snapshot and file glob, then I can just download the tar? Same thing in reverse?

@pauldotknopf
Copy link
Contributor Author

pauldotknopf commented Jan 23, 2018

I just found out that the diff service supports capturing the entire snapshot by providing empty lower mounts.

upperMounts, err := snapshotService.Mounts(ctx, snapshotKey)
if err != nil {
	return err
}

desc, err := diffService.DiffMounts(ctx,
	[]mount.Mount{},
	upperMounts,
	diff.WithMediaType(ocispec.MediaTypeImageLayerGzip),
	diff.WithReference("custom-ref"))

fmt.Println(desc.Digest)

It would be nice if we could apply a globbing pattern.

desc, err := diffService.DiffMounts(ctx,
	[]mount.Mount{},
	upperMounts,
	diff.WithMediaType(ocispec.MediaTypeImageLayerGzip),
	diff.WithGlob("test/*"),
	diff.WithGlob("this-file-too"))

@stevvooe
Copy link
Member

@pauldotknopf Just mount the snapshot and copy to it. Using ctr:

$ sudo ctr run -t docker.io/library/busybox:latest test09 /bin/sh # create a container some how
$ sudo ctr  snapshot mounts /tmp/mymount test09 | xargs sudo # mount its filesystem
$ rsync -av /mydata /tmp/mymount
$ umount /tmp/mymount

You can reproduce this in Go using the snapshot service and the mount helpers.

@pauldotknopf
Copy link
Contributor Author

Oh, cool, I didn't realize that it was supported to mount from the client. I was trying to avoid root access in my client though. Oh well.

Thanks!

@stevvooe
Copy link
Member

Oh, cool, I didn't realize that it was supported to mount from the client. I was trying to avoid root access in my client though. Oh well.

If your client doesn't have permissions to perform the mount, then it won't work. Typically, we recommend that the client be trusted, as it has the ability to execute binaries and enforce policy.

You could, of course, do this entirely as a non-privileged user. Just do the copy into a directory, tar that up as a layer and then import into containerd and use the diff service to apply the changes.

@0xsubi
Copy link

0xsubi commented Nov 9, 2021

Hi @stevvooe
Could you tell me the commands to run to execute this:

Just do the copy into a directory, tar that up as a layer and then import into containerd and use the diff service to apply the changes.

I am new to containerd APIs and trying to emulate what docker cp does.

@0xsubi
Copy link

0xsubi commented Dec 2, 2021

NVM, I figured it out.

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

No branches or pull requests

3 participants