3 releases (breaking)

0.3.0 Aug 10, 2023
0.2.0 Apr 14, 2023
0.1.0 Dec 17, 2021

#883 in Asynchronous

Download history 3/week @ 2023-12-22 9/week @ 2024-01-19 13/week @ 2024-01-26 18/week @ 2024-02-02 39/week @ 2024-02-09 45/week @ 2024-02-16 49/week @ 2024-02-23 29/week @ 2024-03-01 26/week @ 2024-03-08 25/week @ 2024-03-15 17/week @ 2024-03-22 49/week @ 2024-03-29 36/week @ 2024-04-05

130 downloads per month


351 lines

Remote snapshotter extension for containerd

Crates.io docs.rs Crates.io CI

Snapshots crate implements containerd's proxy plugin for snapshotting. It aims hide the underlying complexity of GRPC interfaces, streaming, and request/response conversions and provide one Snapshots trait to implement.

containerd Documentation

Proxy plugins

A proxy plugin is configured using containerd's config file and will be loaded alongside the internal plugins when containerd is started. These plugins are connected to containerd using a local socket serving one of containerd's GRPC API services. Each plugin is configured with a type and name just as internal plugins are.

How to use from containerd

Add the following to containerd's configuration file:

    type = "snapshot"
    address = "/tmp/snap2.sock"

Start daemons and try pulling an image with custom snapshotter:

# Start containerd daemon
$ containerd --config /path/config.toml

# Run remote snapshotter instance
$ cargo run --example snapshotter /tmp/snap2.sock

# Now specify the snapshotter when pulling an image
$ ctr i pull --snapshotter custom docker.io/library/hello-world:latest

Getting started

Snapshotters are required to implement Snapshotter trait (which is very similar to containerd's Snapshotter interface).

struct Example;

impl snapshots::Snapshotter for Example {
    type Error = ();

    async fn stat(&self, key: String) -> Result<Info, Self::Error> {
        info!("Stat: {}", key);

    // ...

    async fn commit(
        name: String,
        key: String,
        labels: HashMap<String, String>,
    ) -> Result<(), Self::Error> {
        info!("Commit: name={}, key={}, labels={:?}", name, key, labels);

The library provides snapshots::server for convenience to wrap the implementation into a GRPC server, so it can be used with tonic like this:

use snapshots::tonic::transport::Server;

    .expect("Serve failed");


~132K SLoC