Extract OCI Archive
Extract the OCI archive structure
mkdir /tmp/oci-extracted
tar -xf /path/to/image.ociarchive -C /tmp/oci-extracted
Get the manifest digest from index.json
MANIFEST=$(jq -r '.manifests[0].digest' /tmp/oci-extracted/index.json \
| cut -d: -f2)
Extract a layer to get the rootfs
For a single-layer image:
LAYER=$(jq -r '.layers[0].digest' \
/tmp/oci-extracted/blobs/sha256/${MANIFEST} | cut -d: -f2)
mkdir /tmp/rootfs
tar -xf /tmp/oci-extracted/blobs/sha256/${LAYER} -C /tmp/rootfs
For multi-layer images, extract each layer in order and overlay them.
Read the image config
The config contains the created timestamp, entrypoint, labels, etc.:
CONFIG=$(jq -r '.config.digest' \
/tmp/oci-extracted/blobs/sha256/${MANIFEST} | cut -d: -f2)
jq . /tmp/oci-extracted/blobs/sha256/${CONFIG}