-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Copy/Move images between users #2979
Comments
So you want to copy it from the root storage to your user storage or from your storage to root? |
Something I would love to have implemented as well |
Supporting this use-case will also fix major part of issue "redundant image pull shall be avoided (rootless & root)" |
Correct. And/or user1 -> user2. However, it would nice if the implementation underneath was actually just "tagging" so I would only have one actual copy of the image on disk. But that is just a nicety. |
theoretically this could be done with a secondary image store shared by everyone. |
I think this might be a skopeo issue. Where we could easily copy between two different containers/storage. |
No update on this issue. Would love to get someone looking at this in the community |
I would like to take this up. /assign |
@kunalkushwaha Thanks. I have been thinking a little about this. Basically allowing tools to grow the ability to copy between different containers storage. Either between users or between hosts. I look forward to your ideas. |
I tried to think from couple of point of views, how to enable sharing of images between different users on a system.
@rhatdan Please share your views on each approaches. |
I am just a regular user and by no means an expert of the internals of skopeo and podman, however I wanted to share a few ideas based on our use case. We plan to have some images to be run by different system users on the same VPS. With the current implementation, this means that the images must be duplicated for each user, which is largely inefficient in terms of disk space. So ideally there would be a way to set "permissions" on a image or blobs, so that other system users can base their images on those. The root user would share them in a way similar to unix permissions (users/groups). It therefore seems to me that the major obstacle is the implementation of such a "permission system". With this in mind, here a few direct comments to the above list of ideas:
Would be nice to have, subject to the above "permission system". E.g an unprivileged user could want to list "system images" shared by root.
A "copy" is quickly achievable with
It would be nice to be able to share only some images, and not the whole store. I do understand that this means setting permissions on a lots of blobs, so I figure that some specialized interface is needed.
With the "permission" idea, it would work like any other file.
This is where the "copy-on-write" would be nice. btrfs? |
The big issue here is permissions on individual files. Using additionalstores will not work since we have to lock the storage. We could potentially fix this in storage to allow storage use without locks, perhaps if mounted read/only. But we still have issues with the ownership of individual files within the image. |
@nalind @vrothberg @giuseppe @mtrmac WDYT? |
I thought about having the possibility to share images among users/system storage (owned by root), but that requires changes in the file system. This should be possible in fuse-overlayfs. The idea is that every file is stored with permissions 0755, so only the owner can modify them, and the original permission is stored in an extended attribute. fuse-overlayfs then could look into different storages, either owned root or inside other users and be able to read all the files/directories there. fuse-overlayfs would then use the data in the xattr to restore the file permissions back so that the container would not see any difference. The main advantage is that there are no copies involved among different storages. if needed the image can still be copied locally to a different storage, but that should not be required. We'd need to mark these shared images specially though, as they cannot be used normally otherwise the file permissions will be wrong (every file in the container has permissions 0755) |
That doesn’t work in all the general ways some in here wish for (BTW the conversation seems to be wavering between just making fresh copies. If an unprivileged user can share a container layer to be used by other users, the unprivileged user owning the layer can maliciously modify the data (any of directory structure, metadata, contents of individual files), attacking at the very least others’ containers, and at least until a complete audit of the c/storage code base and possibly all callers, extremely likely the rest of the others’ accounts as well. Storage that is truly opportunistically shared between unprivileged users requires a trusted (and probably privileged) third party, i.e. a daemon. Or something like the “additional stores” facility, with a fixed and trusted set of content that can be consumed, but not modified or added to, by unprivileged users. I’m not sure what the “will not work since we have to lock the storage” part refers to, that may well be a blocker — but vaguely speaking at a high level, of all the random things mentioned in here, this one seems to at least have a chance of working.:
|
I am also concerned about world writable content like CONTAINER/tmp, /var/tmp. Also access to setuid programs within these directories could cause issues. |
Oh, the contents of the containers (as opposed to the immutable parent layers) needs to definitely stay user-specific and inaccessible to other users; we can only be discussing the immutable layers of committed images (i.e. something pretty close to the “additional stores”); it’s just that even keeping the immutable layers immutable seems pretty difficult. (So, if “additional stores” are unworkable because of some kind of locking problems, everything about the more general sharing concept is probably unworkable by extension.) |
I was talking about the immutable layers of the image. Containers data cannot be shared. Accessing another storage requires to trust the owner. I am not proposing to do/enable by default for all users. We would need to think of another model (checksumming each file?) if we want to use not trusted storages. @rhatdan In such shared model, every file/dir become 0755 so there won't really be any setuid binary hanging around. The permissions will be restored by fuse-overlay on the fly when these files are used in a lower layer, so the container will see the original mask but that is then applied in the user running fuse-overlays context The 0755 for all files makes sure only the owner can really modify these files. |
Checksumming at what point? The attacker can reshuffle the FS structure at any time, or modify a file that the victim has The only way a checksum/verification step would work sense if the verifier also made a private unmodifiable copy as a part of the process — but that’s just extra overhead on top of having unshared per-user stores; I suppose it would save some network bandwidth, but a local HTTP proxy would do that just as well at much lower cost. |
Checksumming each file/directory. Then the checksum is checked after a local copy exists (or a reflink if possible). This could still be faster than duplicating the whole image as most likely not all files are accessed thus needed to be copied. Anyway I think we should look at the trusted case first, where only trusted storages are used |
Maybe we can take a few steps back and first define which problem(s) we're trying to solve? Problem 1) The title of the issue suggests to allow for copying/moving images across storages. I think that's a valuable addition, assuming we find a way to avoid a complex CLI. Problem 2) The comments are pointing to a truly sharing storage across users. Considering the comments, this seems like a rather controversial feature. I prefer to first focus on Problem 1) to provide a simple solution for a rather complex problem. I'd love to see support for moving/copying images across storages in Skopeo, Podman and maybe Buildah:
Given all the permission issues, maybe that's something that should be restricted to root? |
I like @vrothberg simplification. I see this is more of a scp/cp issue for now. The additionalstores stuff would be nice,especially between root and non-root, so we don't have to worry about problems that @mtrmac is talking about. I like to define containers/image as a library that allows you to move OCI images between different types of image storage. What I see us doing is enhancing it or using it to allow us to copy between two containers/storage. Root->dwalsh or vrothberg->dwalsh or dwalsh->root. Obviously this requires a privileged process to complete. |
I allow myself to pitch in again as "just a user". It seems to me that problem 1 is already solved with the current tools:
Instead, the emphasis of the OP and in my previous comment is on the sharing of storage space
Which is basically, as far as I understand, problem 2 (so that "copy+remove" is actually implemented as "share+remove", which would remove the requirement of double as much storage after the copy). |
It’s not obvious how a library can get the necessary privileges, and whether it should be doing anything like that behind the caller’s back (also remember that there isn’t really a Honestly all of this screams “corner case that people would like to dream about but no-one wants to write and maintain all of that complex code” to me, at this point. Using an intermediate As for accidentally forgetting to use |
Wrap the ID or the digest to ErrImageUnknown errors to avoid ambiguity which image is unknown. Consumers of the storage library may have multiple subsequent calls to the storage API where it can be unclear which image is unknown. Wrapping the ID and digest attempts to avoid this ambiguity. Related-to: github.com/containers/podman/issues/2979 Signed-off-by: Valentin Rothberg <[email protected]>
@kunalkushwaha, that's already being worked on in containers/image#611 but more unlikely to get merged any time soon. Note that avoiding such redundant downloads is orthogonal to the request of this issue but very different. |
That would be a bit better because the compressed layers would never be mmap()ed, we already have some infrastructure to deal with untrusted registry storage, and it would be new code explicitly written for such a risky environment. Still, it’s an attack vector (add a
That tries to avoid downloads to a single store; this issue discusses sharing data between multiple container stores owned by multiple mutually untrusted users. |
One way I feel sharing of images can be done without much changes in current workflow is as below.
Please let me know WDYT on this. |
ping @mtrmac @vrothberg |
@giuseppe worked on fuse-overlayfs (containers/fuse-overlayfs#119) to enable initial support. I currently have too many things on my table to think the details through but try to come back to it asap. |
This issue had no activity for 30 days. In the absence of activity or the "do-not-close" label, the issue will be automatically closed within 7 days. |
@giuseppe Any update on this? |
Friendly ping. |
I don't think we have come up with a good solution for this, so I am thinking it might be time to close this issue. |
is there a manual way of moving an image to the root storage then? in the absence of support in the tooling |
I agree. As mentioned above, the tools allow copying images with some intermediate steps. Doing that in one command while addressing all possible permission issues etc., however, is quite tough. |
/kind feature
Description
I often accidentally build an image as the "wrong" user. For example, as me vs as root. I would really like a way to "tag" the image in to the other user so that a) I don't have to build it again; b) it takes up the same space on disk as only one copy. Given the nature of images, as soon as they start to diverge they could just create the new layers in the user that "forked."
I know I could build a container from the image, export it, then import the tarball as the other user but that is pretty tedious and doesn't let me only have "1" copy.
Output of
podman version
:The text was updated successfully, but these errors were encountered: