#container-image #oci #container #docker #podman #image-processing #opencontainers

ocidir

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

5 unstable releases

0.3.1 Sep 20, 2024
0.3.0 Sep 13, 2024
0.2.1 Aug 16, 2024
0.2.0 Jul 23, 2024
0.1.0 Jun 2, 2024

#300 in Unix APIs

Download history 472/week @ 2024-07-22 396/week @ 2024-07-29 245/week @ 2024-08-05 484/week @ 2024-08-12 234/week @ 2024-08-19 360/week @ 2024-08-26 420/week @ 2024-09-02 386/week @ 2024-09-09 675/week @ 2024-09-16 445/week @ 2024-09-23 505/week @ 2024-09-30 223/week @ 2024-10-07 306/week @ 2024-10-14 563/week @ 2024-10-21 410/week @ 2024-10-28 735/week @ 2024-11-04

2,020 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

34KB
672 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_or_else(|| anyhow!("missing Image Index"))?);
# Ok(())
# }

Dependencies

~11–22MB
~363K SLoC