Image value, or through an ImageHandle once you hold one.
Functions
Image.Get()
Example
Example
ErrImageNotFound when no image with that reference is present in the local cache.
Parameters
ctxcontext.ContextCancels the lookup.
referencestringImage reference, e.g.
“python:3.12”.Returns
Metadata handle for the cached image.
error
ErrImageNotFound when the reference is not cached.Image.List()
Example
Example
Parameters
ctxcontext.ContextCancels the listing.
Returns
All cached image handles, newest first.
error
Non-nil on failure.
Image.Inspect()
Example
Example
ImageHandle plus the parsed OCI config and the layer list.
Parameters
ctxcontext.ContextCancels the inspection.
referencestringImage reference, e.g.
“python:3.12”.Returns
Handle, OCI config, and layers.
error
ErrImageNotFound when the reference is not cached.Image.Remove()
Example
Example
force is false, sandboxes that still reference the image cause the call to fail with ErrImageInUse.
Parameters
ctxcontext.ContextCancels the removal.
referencestringImage reference to delete.
forceboolWhen
true, remove even if sandboxes still reference it.Returns
error
ErrImageInUse when in use and force is false.Image.Prune()
Example
Example
Parameters
ctxcontext.ContextCancels the prune.
Returns
Summary of what was reclaimed.
error
Non-nil on failure.
Image.Load()
docker save tarball or an OCI Image Layout archive) into the cache, so locally built images can be used without a registry. Variadic tags apply extra references to the first image in the archive.
Parameters
ctxcontext.ContextCancels the import.
inputPathstringPath to the archive file.
tags…stringExtra references applied to the first image in the archive.
Returns
One handle for every image reference imported.
error
Non-nil on failure.
Example
Example
Image.Save()
outputPath. ImageArchiveDocker (the default; "" behaves the same) writes an archive loadable with docker load; ImageArchiveOCI writes an OCI Image Layout archive. Returns ErrImageNotFound when any reference is missing from the local cache.
Parameters
ctxcontext.ContextCancels the export.
references[]stringImage references to export, e.g.
“python:3.12”.outputPathstringPath of the archive file to write.
formatImageArchiveFormatImageArchiveDocker (default; "" behaves the same) or ImageArchiveOCI.Returns
error
ErrImageNotFound when any reference is not cached.Example
Example
Methods
Instance methods on*ImageHandle, the metadata reference returned by Image.Get and Image.List. The accessors are pure reads of cached metadata; only Remove and Inspect take a context and reach the runtime.
h.Reference()
"docker.io/library/python:3.12".
Returns
string
Image reference.
h.ManifestDigest()
Returns
string
Manifest digest, or empty.
h.Architecture()
Returns
string
Architecture, or empty.
h.OS()
Returns
string
Operating system, or empty.
h.LayerCount()
Returns
uint
Layer count.
h.SizeBytes()
nil when unknown.
Returns
*int64
Total size in bytes, or
nil.h.CreatedAt()
time.Time when unknown.
Returns
time.Time
First-pulled time, or the zero value.
h.LastUsedAt()
time.Time when unknown.
Returns
time.Time
Last-referenced time, or the zero value.
h.Remove()
Example
Example
Image.Remove(ctx, h.Reference(), force). When force is false, sandboxes that still reference the image cause the call to fail with ErrImageInUse.
Parameters
ctxcontext.ContextCancels the removal.
forceboolWhen
true, remove even if sandboxes still reference it.Returns
error
ErrImageInUse when in use and force is false.h.Inspect()
Example
Example
Image.Inspect(ctx, h.Reference()).
Parameters
ctxcontext.ContextCancels the inspection.
Returns
Handle, OCI config, and layers.
error
Non-nil on failure.
Types
ImageHandle
Returned by Image.Get() · Image.List()
A lightweight metadata reference to a cached OCI image. Fields are unexported; read them through the accessor methods below. Embedded inImageDetail.
ImageDetail
Returned by Image.Inspect() · Inspect()
Bundles anImageHandle (embedded, so all its accessors are promoted) with the parsed OCI config and layer list.
ImageConfig
Used by ImageDetail.Config
The parsed OCI config block.ImageLayer
Used by ImageDetail.Layers
One layer of an image manifest.ImagePruneReport
Returned by Image.Prune()
Summarizes the artifacts removed byImage.Prune.
ImageArchiveFormat
Used by Image.Save()
Selects the archive layout written byImage.Save.