LinuxCommandLibrary

crane-validate

Validate CloudEvents data against schema

TLDR

Validate an image

$ crane validate
copy

Skip downloading/digesting layers
$ crane validate --fast
copy

Name of remote image to validate
$ crane validate --remote [image_name]
copy

Path to tarball to validate
$ crane validate --tarball [path/to/tarball]
copy

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

SYNOPSIS

crane validate [options] <image> [<layers>...]

PARAMETERS

-a, --all-platforms
    Validate all platforms in multi-platform index manifests

-c, --checksum <string>
    Expected checksum; fails if image digest mismatches

-d, --dry-run
    List violations without non-zero exit code

-v, --verbose
    Enable verbose logging for detailed diagnostics

DESCRIPTION

The crane validate command is part of the crane CLI tool from the Google go-containerregistry project. It verifies that a given OCI image or artifact conforms to the OCI Image Specification and OCI Image Layout.

When invoked, it fetches the image manifest or index from a remote registry, parses it, and checks:
• Validity of JSON structures in manifests and configs.
• Content-addressable storage (CAS) for layers via digests.
• Proper media types.
• Platform-specific validations if specified.

It reports violations like mismatched digests, invalid media types, or missing required fields. Use --dry-run to list issues without exiting non-zero, ideal for CI/CD pipelines. Primarily for remote images (e.g., docker.io/library/nginx:latest), it supports multi-platform indexes with --all-platforms.

Essential for ensuring image integrity before deployment, especially in secure supply chains with Sigstore/cosign integration.

CAVEATS

Requires network access for remote images; local tarballs unsupported; does not verify signatures (use cosign verify).

EXAMPLES

Basic: crane validate docker.io/library/alpine:latest
Dry-run: crane validate -d gcr.io/project/image:tag
Multi-platform: crane validate -a docker.io/library/nginx:latest

EXIT CODES

0: Valid image
1: Validation failures (use -d to inspect without error)

HISTORY

Introduced in crane v0.2.0 (2020) as part of go-containerregistry by Google; evolved with OCI v1.1 support in later releases for enhanced multi-arch validation.

SEE ALSO

crane(1), skopeo(1), regctl(1), cosign(1)

Copied to clipboard