containerd-shim-wasm

Crates.iocontainerd-shim-wasm
lib.rscontainerd-shim-wasm
version0.8.0
sourcesrc
created_at2023-03-06 21:31:37.004867
updated_at2024-12-04 22:47:50.64168
descriptionLibrary for building containerd shims for wasm
homepagehttps://github.com/containerd/runwasi
repositoryhttps://github.com/containerd/runwasi
max_upload_size
id803015
size199,573
runwasi-committers (github:containerd:runwasi-committers)

documentation

README

runwasi logo

containerd-shim-wasm

A library to help build containerd shims for wasm workloads.

Usage

Implement the Instance trait, then call run, for example,

use std::time::Duration;
use chrono::{DateTime, Utc};

use containerd_shim as shim;
use containerd_shim_wasm::sandbox::{Error, Instance, InstanceConfig, ShimCli};

struct MyInstance {
    // ...
}

impl Instance for MyInstance {
    type Engine = ();

   fn new(_id: String, _cfg: Option<&InstanceConfig<Self::Engine>>) -> Result<Self, Error> {
       todo!();
    }
    fn start(&self) -> Result<u32, Error> {
       todo!();
    }
    fn kill(&self, signal: u32) -> Result<(), Error> {
       todo!();
    }
    fn delete(&self) -> Result<(), Error> {
       todo!();
    }
    fn wait_timeout(&self, t: impl Into<Option<Duration>>) -> Option<(u32, DateTime<Utc>)> {
       todo!();
    }
}

shim::run::<ShimCli<MyInstance>>("io.containerd.myshim.v1", None);

containerd expects the shim binary to be installed into $PATH (as seen by the containerd process) with a binary name like containerd-shim-myshim-v1 which maps to the io.containerd.myshim.v1 runtime which would need to be configured in containerd. It (containerd) also supports specifying a path to the shim binary but needs to be configured to do so.

This crate is not tied to any specific wasm engine.

Commit count: 1394

cargo fmt