microsandbox-image
Pull OCI container images, extract their layers, and cache everything locally. This crate handles the full image lifecycle for microsandbox — from resolving a multi-platform manifest to producing ready-to-mount layer directories.
- Multi-platform resolution — automatically picks the right manifest for your OS and architecture
- Parallel downloads — all layers download and extract concurrently with SHA256 verification
- Content-addressable caching — duplicate layers across images are stored once, with cross-process safety via
flock() - Progress streaming — real-time events for download, extraction, and indexing stages
- Sidecar indexes — builds binary indexes per layer for fast OverlayFs lookups at runtime
Quick Start
use ;
let cache = new?;
let platform = host_linux;
let registry = new?;
let reference = "docker.io/library/alpine".parse?;
let result = registry.pull.await?;
// Extracted layer directories, bottom-to-top
for layer_path in &result.layers
// Parsed image config (env, cmd, entrypoint, user, etc.)
println!;
println!;
Authentication
use RegistryAuth;
// Public registries — no credentials needed
let registry = new?;
// Private registries
let auth = Basic ;
let registry = with_auth?;
Pull Policies
Control when the crate contacts the registry vs. uses the local cache.
use ;
// Use cache if available, download otherwise (default)
let opts = PullOptions ;
// Always fetch a fresh manifest, but reuse cached layers by digest
let opts = PullOptions ;
// Cache-only — error if the image isn't already cached
let opts = PullOptions ;
Progress Reporting
Stream progress events while the download runs in the background.
let = registry.pull_with_progress;
spawn;
let result = task.await??;
Multi-Platform Images
Fat manifests (OCI Image Index) are automatically resolved to your target platform. Platform::host_linux() detects the current architecture by default.
use Platform;
// Auto-detect (e.g. linux/amd64 or linux/arm64)
let platform = host_linux;
// Explicit platform
let platform = new;
// With variant (e.g. armv7)
let platform = with_variant;