dockerarchive

package
v1.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package dockerarchive reads container images in the docker-archive format — what `podman save --format docker-archive` writes, and `docker save` in its classic layout — as a stream, resolving the layers into the final root filesystem view of the files a caller chose to capture. It knows nothing about what the files mean.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoManifest        = errors.New("no manifest in archive")
	ErrAmbiguousManifest = errors.New("archive holds several images and none matches the reference")
	ErrLayerMissing      = errors.New("layer named by the manifest missing from archive")
	ErrUnsupportedLayer  = errors.New("unsupported layer compression")
	ErrEntryTooLarge     = errors.New("archive entry too large")
)

Functions

This section is empty.

Types

type Capture

type Capture func(filePath string, header *tar.Header, reader *bufio.Reader) (any, error)

Capture is called for every regular file in every layer, with the reader positioned at the file's content (it ends at the file's end). It returns the payload to keep for the file, or nil to keep nothing. Files that are later deleted or replaced by an upper layer do not reach the resolved image.

type File

type File struct {
	// Path is the path inside the image, without a leading slash.
	Path string
	// Layer is the index, in the manifest's order, of the layer the file came from.
	Layer   int
	Payload any
}

File is a captured file as it exists in the final image.

type Image

type Image struct {
	// Id is the image ID, "sha256:<digest of the config>".
	Id       string
	RepoTags []string
	// Layers are the layer archive names in the manifest's order (lowest first).
	Layers []string
	// LayerDigests are the layers' diff IDs ("sha256:..."), in the same order, from the image config; when the
	// config does not carry them, they are derived from the archive names.
	LayerDigests []string
	// Files maps each captured path to the file as the top-most layer left it.
	Files map[string]*File
}

Image is the resolved view of one image in the archive.

func Read

func Read(reader io.Reader, reference string, capture Capture) (*Image, error)

Read reads a docker-archive stream and resolves the image it holds. When the archive holds several images, the one whose repo tags name the reference is chosen; an empty reference requires the archive to hold exactly one image.

func (*Image) LayerDigest

func (image *Image) LayerDigest(index int) string

LayerDigest is the diff ID of the layer at the given index, or "" when there is none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL