Skip to content

Add composefs-run a minimal crun based container starter#308

Draft
alexlarsson wants to merge 1 commit into
mainfrom
composefs-run
Draft

Add composefs-run a minimal crun based container starter#308
alexlarsson wants to merge 1 commit into
mainfrom
composefs-run

Conversation

@alexlarsson

@alexlarsson alexlarsson commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This is an experiment to see how a composefs native podman run would look. Its around 700 lines, and depends only on crun. It supports a pretty small subset of the "podman run" options, but the ones it has actually cover a great part of the things in wide use.

All containers are stateless on the host. There is no database of running containers, etc. All the state for the container are in a tmpfs that is mounted in a namespace and freed automatically on container exit. By default the writable layer of the container is in thet tmpfs as well, but you can pass separate
--overlayfs-upperdir/workdir options to store the state somewhere.

Note: I'm not sure this is something we want, and if we do, if this is the right places for it (in a separate binary). I'm just putting this out as an idea.

@alexlarsson alexlarsson marked this pull request as draft June 5, 2026 14:41
@alexlarsson

Copy link
Copy Markdown
Contributor Author

In use:

$ cfsctl --repo repo oci pull docker://quay.io/centos/centos:10 cs10
$ sudo composefs-run --repo repo -it cs10 -- head -2 /etc/os-release 
NAME="CentOS Stream"
VERSION="10 (Coughlan)"

This is an experiment to see how a composefs native podman run would
look. Its around 700 lines, and depends only on crun. It supports a
pretty small subset of the "podman run" options, but the ones it has
actually cover a great part of the things in wide use.

All containers are stateless on the host. There is no database of
running containers, etc. All the state for the container are in a
tmpfs that is mounted in a namespace and freed automatically on
container exit. By default the writable layer of the container is in
thet tmpfs as well, but you can pass separate
--overlayfs-upperdir/workdir options to store the state somewhere.

Assisted-by: Claude Code (Opus 4.6)
Signed-off-by: Alexander Larsson <alexl@redhat.com>

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I did a quick PoC of a similar thing in c0bac64

In Python primarily to demonstrate the cross-process thing via varlink; I think it'd make sense to do the same thing here sorry that's a lie that was a previous iteration

.context("Making / recursively private")?;

// Attach the bundle tmpfs and composefs rootfs mount
let bundle_dir = "/run/composefs-run";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this hardcoded path is a good idea.

When I looked at the OCI runtime spec...I wondered why the heck it isn't supported to pass a file descriptor for the rootfs mount in a clear way.

Anyways surely at least it's work-aroudable via passing a /proc/self/fd/N?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to avoid it using /proc/self/fd/N but it didn't work for pivot root in crun. But, we could really use any pre-existing directory for this really.

};

// crun create: set up the container but don't start it yet
let status = Command::new("crun")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Presumably this could also use https://github.com/youki-dev/youki - probably worth having minimal support for configuring it

repo: &Repository<ObjectID>,
image: &str,
) -> Result<(ObjectID, composefs_oci::OpenConfig<ObjectID>)> {
let img = if let Some(digest_str) = image.strip_prefix('@') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@cgwalters

Copy link
Copy Markdown
Collaborator

Note: I'm not sure this is something we want, and if we do, if this is the right places for it (in a separate binary). I'm just putting this out as an idea.

I think it'd make total sense to have a separate composefs-examples repo? WDYT?

@alexlarsson

Copy link
Copy Markdown
Contributor Author

@cgwalters composefs-examples sounds like a good idea to me.

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.

2 participants