crane-index-filter
Filter container image indexes
TLDR
Modify remote index
Specify the platform(s) to keep from base in the form os/arch/variant:osversion,platform
Tag to apply to resulting image
Display help
SYNOPSIS
crane index-filter <INDEX> <FILTER> [-o <OUTPUT>] [--platform <PLATFORM>]...
PARAMETERS
-o, --output <OUTPUT>
File path for filtered index output (stdout if omitted)
--platform <PLATFORM>
Deprecated: Filter by OS/arch (e.g., linux/amd64). Repeatable; use CEL filter instead
-h, --help
Print command usage and exit
DESCRIPTION
crane index-filter is a subcommand of the crane CLI tool from Google's go-containerregistry project. It processes OCI (Open Container Initiative) image indexes, which aggregate manifests for multi-platform container images supporting various OS/architectures.
The command evaluates a user-provided CEL (Common Expression Language) filter expression against each manifest's platform metadata, retaining only those where the expression returns true. Accessible fields include os, architecture (or arch), osVersion, variant, features (array of strings), and annotations (map).
Example:
crane index-filter multiarch.index.json 'os == "linux" && (architecture == "amd64" || architecture == "arm64")' -o linux-amd64-arm64.index.json
This creates slimmed-down indexes for specific platforms, ideal for distribution, testing, or deployment in constrained environments. Output is a new OCI index JSON, compatible with tools like crane push or container runtimes.
Supports local files or registry URLs for input indexes. Enhances workflow efficiency by avoiding full multi-arch pulls.
CAVEATS
CEL filter must evaluate to boolean; syntax errors fail entire command. Input must be valid OCI index. Deprecated --platform ignores complex metadata like features/annotations.
CEL FILTER VARIABLES
os (string), architecture (string), osVersion (string), variant (string), features (array), annotations (map[string]string). Supports ==, !=, &&, ||, has(), size(), etc. See CEL spec.
INPUT SOURCES
Local JSON files or remote: crane://ghcr.io/user/image@sha256:... or tag refs.
HISTORY
Added in crane v0.10.0 (May 2021) within google/go-containerregistry. Evolved with CEL support for expressive filtering; prior versions used simpler platform flags.


