fussybeaver / bollard

Docker daemon API in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Youki as runtime

Ludea opened this issue · comments

commented

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

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..

commented

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.

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.

commented

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

Hello 👋, 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 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.

commented

@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