8 releases (breaking)

0.8.0 Dec 4, 2024
0.7.0 Oct 7, 2024
0.6.0 May 23, 2024
0.5.0 Mar 20, 2024
0.1.2 Mar 7, 2023

#153 in WebAssembly

Download history 22/week @ 2024-09-11 32/week @ 2024-09-18 15/week @ 2024-09-25 197/week @ 2024-10-02 87/week @ 2024-10-09 17/week @ 2024-10-16 13/week @ 2024-10-23 50/week @ 2024-10-30 55/week @ 2024-11-06 8/week @ 2024-11-13 4/week @ 2024-11-20 155/week @ 2024-12-04 69/week @ 2024-12-11 3/week @ 2024-12-18

227 downloads per month

Apache-2.0

320KB
4.5K SLoC

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.

Dependencies

~36–54MB
~1M SLoC