#docker #oci #podman-container #podman #open-containers

ocidir

A Rust library for reading and writing OCI (opencontainers) layout directories

8 releases (5 breaking)

Uses new Rust 2024

0.6.0 Sep 4, 2025
0.5.0 Jul 10, 2025
0.4.0 Jun 17, 2025
0.3.1 Sep 20, 2024
0.1.0 Jun 2, 2024

#247 in Unix APIs

Download history 2614/week @ 2025-08-27 3907/week @ 2025-09-03 3610/week @ 2025-09-10 2249/week @ 2025-09-17 1231/week @ 2025-09-24 1125/week @ 2025-10-01 778/week @ 2025-10-08 824/week @ 2025-10-15 1107/week @ 2025-10-22 1184/week @ 2025-10-29 1432/week @ 2025-11-05 1621/week @ 2025-11-12 1580/week @ 2025-11-19 1063/week @ 2025-11-26 2348/week @ 2025-12-03 2478/week @ 2025-12-10

7,823 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

43KB
853 lines

ocidir

Crates.io

docs.rs

Read and write to OCI image layout directories

This library contains medium and low-level APIs for working with OCI images, which are basically a directory with blobs and JSON files for metadata.

Dependency on cap-std

This library makes use of cap-std to operate in a capability-oriented fashion. In practice, the code in this project is well tested and would not traverse outside its own path root. However, using capabilities is a generally good idea when operating in the container ecosystem, in particular when actively processing tar streams.

Examples

To access an existing OCI directory:

# use ocidir::cap_std;
# use anyhow::{anyhow, Result};
# fn main() -> anyhow::Result<()> {
let d = cap_std::fs::Dir::open_ambient_dir("/path/to/ocidir", cap_std::ambient_authority())?;
let d = ocidir::OciDir::open(d)?;
println!("{:?}", d.read_index()?);
# Ok(())
# }

Dependencies

~11–26MB
~365K SLoC