LinuxCommandLibrary

crane-index

Generate an index for container images

TLDR

Modify an image index

$ crane index
copy

Modify an image index with subcommand
$ crane index [subcommand]
copy

Display help
$ crane index [[-h|--help]]
copy

SYNOPSIS

crane index [OPTIONS] IMAGE [IMAGE ...]

PARAMETERS

--platform
    Platforms to include (e.g., 'linux/amd64,linux/arm64')

--platform-file
    File listing platforms, one per line

--expected-platform
    Require input images to match these platforms

--annotation =
    Add annotation to index manifest (repeatable)

--registry-mirror
    Use registry mirror for pulls (repeatable)

DESCRIPTION

The crane index command constructs an OCI (Open Container Initiative) image index manifest from one or more specified container images. This is essential for creating multi-platform "fat" manifests that reference images across different architectures and operating systems, such as linux/amd64 and linux/arm64.

It resolves the manifests of input images, validates platforms, and generates a top-level index.json that lists them as instances. This enables tools like Docker or containerd to select the appropriate image based on the runtime environment. Users specify platforms to include or expect, add annotations for metadata, and use registry mirrors for private repos.

Common use cases include building universal images for CI/CD pipelines, Kubernetes deployments supporting ARM and x86, or archiving image sets. Output can be saved to a file or piped directly to crane push for publishing to a registry. Crane ensures compatibility with OCI specs, handling digests and media types correctly.

Part of the crane toolkit by GoogleContainerTools, it simplifies image manipulation without full pulls, using efficient manifest fetching.

CAVEATS

Requires network access to fetch image manifests; does not pull layers. Input images must exist and be accessible. Output is JSON only, not a full image.

EXAMPLES

crane index alpine:3.18@sha256:abc... alpine:3.18@sha256:def... > index.json
crane index --platform linux/amd64,linux/arm64 --platform linux/arm/v7 img1 img2 | crane push ghcr.io/user/multi:v1

HISTORY

Developed as part of the crane project by GoogleContainerTools, starting around 2020. Gained prominence with OCI adoption; v0.13+ refined multi-arch support.

SEE ALSO

crane(1), skopeo(1), regctl(1), img(1)

Copied to clipboard