Image
Factory for sandbox image sources.Image.oci()
Example
Example
root_disk to configure its writable layer with a RootDisk factory result. An integer is shorthand for a managed disk of that size in MiB.
Parameters
referencestr“python:3.12”.root_diskRootDiskConfig | int | Noneupper_size_mibint | Noneroot_disk=RootDisk.managed(…).Returns
image=.Image.bind()
Example
Example
Parameters
pathstrReturns
image=.Image.disk()
Example
Example
fstype when the filesystem type cannot be auto-detected.
Parameters
pathstr.qcow2, .raw, .vmdk).fstypestr | None“ext4”. None auto-detects.Returns
image=.Cache management
These static methods inspect and prune images already pulled into the local OCI cache.Local image cache
Image.get()
Example
Example
ImageNotFoundError when the image is not present in the local cache.
Parameters
referencestrReturns
Image.list()
Example
Example
Returns
Image.inspect()
Example
Example
Parameters
referencestrReturns
Image.remove()
Example
Example
force is False, an image still referenced by one or more sandboxes raises ImageInUseError; pass force=True to remove it anyway.
Parameters
referencestrforceboolFalse.Image.prune()
Example
Example
Returns
Image.load()
docker save tarballs and OCI Image Layout archives, so locally built images can be used without going through a registry.
Parameters
input_pathstr”-” to read the archive from stdin.tagstr | NoneReturns
Example
Example
Image.save()
ImageNotFoundError when any reference is not in the local cache, and ValueError for an empty reference list.
Parameters
referencestr | Sequence[str]output_pathstrformatImageArchiveFormatDOCKER.Example
Example
ImageHandle
Returned by get() · list() · load()
A lightweight handle to a cached OCI image, returned byImage.get(), Image.list(), and Image.load(). Properties are read-only attributes; the two methods are async.
handle.reference
str
Image reference
handle.size_bytes
int \| None
Total size in bytes, or None when unknown
handle.manifest_digest
str \| None
Content-addressable manifest digest
handle.architecture
str \| None
Resolved architecture
handle.os
str \| None
Resolved operating system
handle.layer_count
int
Number of layers
handle.last_used_at
float \| None
Last referenced time, milliseconds since epoch
handle.created_at
float \| None
First-pulled time, milliseconds since epoch
handle.inspect()
Returns
ImageDetail
handle.remove()
ImageInUseError unless force)
RootDisk
Factory for writable OCI root disk configurations.RootDisk.managed()
Returns
RootDiskConfig
RootDisk.tmpfs()
Returns
RootDiskConfig
RootDisk.disk()
Returns
RootDiskConfig
Types
ImageSource
Returned by oci() · bind() · disk()
Explicit rootfs image source. Build one withImage.oci(), Image.bind(), or Image.disk(), then pass it as the image= kwarg to Sandbox.create(). A frozen dataclass; treat its fields as opaque.
RootDiskConfig
Frozen root disk configuration produced byRootDisk.
ImageDetail
Returned by inspect() · ImageHandle.inspect()
Full detail for a cached image: the core handle, the parsed OCI config block, and per-layer metadata.ImageConfigDetail
Used by ImageDetail.config
OCI image config fields extracted from the local cache.ImageLayerDetail
Used by ImageDetail.layers
Metadata for a single image layer.ImagePruneReport
Returned by prune()
Summary of cached image data removed byImage.prune().
DiskImageFormat
Used by ImageSource._format
Disk image container format.ImageArchiveFormat
Used by Image.save(format=…)
Archive layout used when exporting cached images.ImageSourceKind
Returned in ImageSource._type
Root filesystem source kind.RootDiskKind
Returned in RootDiskConfig.kind
Writable OCI root disk implementation.Errors
Image operations raise these typed exceptions, all subclasses ofMicrosandboxError.