bollard icon indicating copy to clipboard operation
bollard copied to clipboard

Youki as runtime

Open Ludea opened this issue 1 year ago • 7 comments

It would be awesome if you could support Youki as container runtime

Ludea avatar Mar 13 '23 13:03 Ludea

That is really interesting I hadn't heard of that project. Initially not quite sure how or if an integration would work - e.g. can you use Youki as a library without Docker/Portman ? I'll need to look a little closer..

fussybeaver avatar Mar 13 '23 21:03 fussybeaver

You can run youki as standalone app : https://containers.github.io/youki/user/basic_usage.html#using-youki-standalone

It can create OCI container https://github.com/containers/youki/tree/main/crates/liboci-cli.

You can also replace docker runtime (runc) , with youki.

I think, the best way to integrate youki to bollard is to provide a cli to parse dockerfile and create image through youki with dockerfile.

Ludea avatar Mar 14 '23 07:03 Ludea

Parsing the Dockerfile is big enough to be a project on its own (e.g. buildkit)... I can imagine perhaps translating the API and struct definitions in Bollard into Youki configuration - although you are missing the rootfs file structure to actually run it. I guess the challenge is finding out what it takes to do that.

fussybeaver avatar Mar 14 '23 13:03 fussybeaver

We can get remote rootfs with container config https://containers.gitbook.io/build-containers-the-hard-way/#container-configuration

Or create the busybox rootfs

[root@node01 test]# docker run -it busybox /bin/sh
/ # ls /
bin   dev   etc   home  proc  root  sys   tmp   usr   var

Ludea avatar Mar 15 '23 15:03 Ludea

Hello :wave:, isn't youki (or any other alternative runtime) already supported through the use of the HostConfig#runtime field, when creating a new container ?

Something like

use bollard::{container::Config, Docker, models::HostConfig};

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let docker = Docker::connect_with_socket_defaults().unwrap();

    let config = Config {
        image: Some("hashicorp/http-echo:latest"),
        host_config: Some(HostConfig {
            runtime: Some("youki".to_string()),
            ..Default::default()
        }),
        ..Default::default()
    };

    let container_id = &docker.create_container::<&str, &str>(None, config).await?.id;

    let _ = &docker.start_container::<String>(&container_id, None).await?;

    Ok(())
}

ledoyen avatar Apr 24 '23 20:04 ledoyen

@ledoyen I think you're right, if you setup your docker daemon to use youki as a runtime. Perhaps though it might be more useful to be able to trigger youki directly from Bollard, as you will not need the Docker server at all.

fussybeaver avatar Apr 25 '23 19:04 fussybeaver

@ledoyen I think you're right, if you setup your docker daemon to use youki as a runtime. Perhaps though it might be more useful to be able to trigger youki directly from Bollard, as you will not need the Docker server at all.

Yes, it would be awesome to avoid Docker and to get a native rust container engine, with cli support like buildkit

Ludea avatar Apr 28 '23 05:04 Ludea