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

Question: Supporting modifications to a read-only rootfs #1594

Open
maleadt opened this issue Oct 28, 2024 · 1 comment
Open

Question: Supporting modifications to a read-only rootfs #1594

maleadt opened this issue Oct 28, 2024 · 1 comment

Comments

@maleadt
Copy link
Contributor

maleadt commented Oct 28, 2024

(This is more of a question, but I wasn't sure where to post this other than the issue tracker.)

I'm trying to use crun as the back-end for a sandboxing tool that makes it possible to modify a container's root filesystem, optionally persisting the changes into a separate user directory. I'm having some trouble mapping that onto an OCI bundle that works with `crun.

First of all, as per the spec the root key is mandatory, but since I don't actually want to mutate the sources of the rootfs I'm setting readonly=true.

I figured I could then (kind of redundantly) mount the root again, but now using an overlay mount to persist the changes:

"root": {
    "path": "/rootfs",
    "readonly": true
},
"mounts": [
    {
        "destination": "/",
        "type": "overlay",
        "options": [
            "lowerdir=/rootfs",
            "upperdir=/overlay/upper",
            "workdir=/overlay/work",
            "userxattr"
        ]
    },
]

crun doesn't accept that, however. Well, more specifically the overlay mount fails with EINVAL.

Looking at a bundle generated by Docker, which supports this, the root is actually writable and pointing to e.g. a btrfs subvolume. I would like to avoid that, because it requires the caller to set-up an overlay-like mechanism to make the root writable, while I'd prefer crun to handle all that (with the added benefit of easy clean-up when the container exits). Is this possible, or outside of the scope of crun? Any other suggestions would be appreciated as well!

@giuseppe
Copy link
Member

the traditional way of handling it, as you've pointed out, is to create an overlay mount and then use it as the path for root.

I am not against adding this possibility to crun if anyone cares to implement it, but it is quite easy to do externally, and if you care about "auto cleanup", you can unshare a mount namespace first and create the overlay mount there.

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

2 participants