Skip to main content
The Python SDK exposes local OCI image-cache operations through Image. These APIs inspect and prune images that have already been pulled by sandbox creation. Image also remains the namespace for explicit rootfs source configuration such as Image.oci(...), Image.bind(...), and Image.disk(...).
from microsandbox import Image

Image


Image.get()

async def Image.get(reference: str) -> ImageHandle
Fetch one cached image by reference. Raises ImageNotFoundError when the image is not present in the local cache.

Image.list()

async def Image.list() -> list[ImageHandle]
Return every cached image, ordered newest first.
images = await Image.list()
for image in images:
    print(image.reference, image.layer_count)

Image.inspect()

async def Image.inspect(reference: str) -> ImageDetail
Return handle metadata plus parsed OCI config and layer details.

Image.remove()

async def Image.remove(reference: str, *, force: bool = False) -> None
Delete a cached image. When force is false, sandboxes still referencing the image raise ImageInUseError.

Image.prune()

async def Image.prune() -> ImagePruneReport
Remove cached image data that is not used by any sandbox or indexed snapshot. The returned report includes the count of removed refs, manifests, layers, fsmeta files, VMDK files, and any measured bytes reclaimed.

ImageHandle

Returned by Image.get() and Image.list().
Property / MethodTypeDescription
referencestrImage reference
manifest_digeststr | NoneContent-addressable manifest digest
architecturestr | NoneResolved architecture
osstr | NoneResolved operating system
layer_countintNumber of layers
size_bytesint | NoneTotal size, or None when unknown
created_atfloat | NoneFirst-pulled time as milliseconds since epoch
last_used_atfloat | NoneLast referenced time as milliseconds since epoch
await remove(force=False)NoneDelete this image
await inspect()ImageDetailFetch full detail for this image

ImageDetail

PropertyTypeDescription
handleImageHandleCore cached image metadata
configImageConfigDetail | NoneParsed OCI config block
layerslist[ImageLayerDetail]Layers in bottom-to-top order

ImageConfigDetail

PropertyType
digeststr
envlist[str]
cmdlist[str] | None
entrypointlist[str] | None
working_dirstr | None
userstr | None
labelsdict[str, Any] | None
stop_signalstr | None

ImageLayerDetail

PropertyType
diff_idstr
blob_digeststr
media_typestr | None
compressed_size_bytesint | None
erofs_size_bytesint | None
positionint

ImagePruneReport

PropertyType
image_refs_removedint
manifests_removedint
layers_removedint
fsmeta_removedint
vmdk_removedint
bytes_reclaimedint | None