microsandbox-image
Pull OCI container images and cache ready-to-mount filesystem artifacts locally. This crate handles the full image lifecycle for microsandbox — from resolving a multi-platform manifest to producing per-layer EROFS images, fsmeta, and the VMDK descriptor used by the VM.
- Multi-platform resolution — automatically picks the right manifest for your OS and architecture
- Parallel materialization — layers download, verify, ingest, and materialize concurrently
- Content-addressable caching — duplicate layers across images are stored once, with cross-process safety via
flock() - Progress streaming — real-time events for download, layer materialization, and fsmeta/VMDK stitching stages
Quick Start
use Path;
use ;
let cache = new?;
let platform = host_linux;
let registry = new?;
let reference = "docker.io/library/alpine".parse?;
let result = registry.pull.await?;
// Materialized layer diff_ids, bottom-to-top
for diff_id in &result.layer_diff_ids
// 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 = builder.auth.build?;
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.
use PullProgress;
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;