Image value, or through an ImageHandle once you hold one.
Typical flow
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.
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.
| Method | Returns | Description |
|---|---|---|
| Reference() | string | Image reference |
| ManifestDigest() | string | Content-addressable manifest digest, or empty |
| Architecture() | string | Resolved architecture, or empty |
| OS() | string | Resolved operating system, or empty |
| LayerCount() | uint | Number of layers |
| SizeBytes() | *int64 | Total size in bytes, or nil when unknown |
| CreatedAt() | time.Time | First-pulled time, or the zero value |
| LastUsedAt() | time.Time | Last-referenced time, or the zero value |
| Remove(ctx, force) | error | Delete this image |
| Inspect(ctx) | (*ImageDetail, error) | Fetch full detail for this image |
ImageDetail
Returned by Image.Inspect() · Inspect()
Bundles anImageHandle (embedded, so all its accessors are promoted) with the parsed OCI config and layer list.
| Field | Type | Description |
|---|---|---|
*ImageHandle | *ImageHandle | Embedded metadata handle (accessors promoted) |
| Config | *ImageConfig | Parsed OCI config block |
| Layers | []ImageLayer | Layers in manifest order |
ImageConfig
Used by ImageDetail.Config
The parsed OCI config block.| Field | Type | Description |
|---|---|---|
| Digest | string | Config blob digest |
| Env | []string | Environment variables (KEY=VALUE) |
| Cmd | []string | Default command |
| Entrypoint | []string | Entrypoint |
| WorkingDir | string | Working directory |
| User | string | Default user |
| Labels | map[string]string | OCI labels |
| StopSignal | string | Stop signal |
ImageLayer
Used by ImageDetail.Layers
One layer of an image manifest.| Field | Type | Description |
|---|---|---|
| DiffID | string | Uncompressed layer diff ID |
| BlobDigest | string | Compressed blob digest |
| MediaType | string | Layer media type |
| CompressedSizeBytes | *int64 | Compressed size in bytes, or nil |
| ErofsSizeBytes | *int64 | EROFS size in bytes, or nil |
| Position | int32 | Index in the layer stack |
ImagePruneReport
Returned by Image.Prune()
Summarizes the artifacts removed byImage.Prune.
| Field | Type | Description |
|---|---|---|
| ImageRefsRemoved | uint32 | Image references removed |
| ManifestsRemoved | uint32 | Manifests removed |
| LayersRemoved | uint32 | Layers removed |
| FsmetaRemoved | uint32 | Fsmeta files removed |
| VMDKRemoved | uint32 | VMDK files removed |
| BytesReclaimed | *uint64 | Bytes reclaimed, or nil when unknown |