TExcelTAD
Home › Software Supply Chain Security: SBOM, SLSA & Sigstore › crane & oras: Copying Images & Artifacts

crane & oras: Copying Images & Artifacts

Two small command-line tools cover most registry work in a supply-chain pipeline, without a Docker daemon:

Tool From Best at
crane Google's go-containerregistry images: copy, tag, inspect, append layers, mutate configs, export file systems
oras the ORAS project (CNCF) any artifact: push files (SBOMs, Helm charts, WASM modules, policy bundles) to a registry, attach them to images, discover what's attached

Both talk to localhost:5000 over plain HTTP here. crane allows HTTP for localhost automatically; oras needs --plain-http. Against a real registry, both use your Docker credentials (~/.docker/config.json) or their own login commands.

Promoting an image without changing it

A common release flow builds once into a staging repository, tests, then promotes the exact same digest to production. crane copy copies manifests and blobs byte for byte, so the digest, and every signature attached to it, stays valid:

bash · try it yourself
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/staging/app:build-42 > /dev/null 2>&1
crane copy localhost:5000/staging/app:build-42 localhost:5000/prod/app:1.4.2 2>&1 | grep -v 'mounted blob'   # blob lines arrive in parallel
crane tag localhost:5000/prod/app:1.4.2 stable
echo "staging: $(crane digest localhost:5000/staging/app:build-42)"
echo "prod:    $(crane digest localhost:5000/prod/app:1.4.2)"
crane ls localhost:5000/prod/app
crane catalog localhost:5000
2026/10/23 21:57:03 Copying from localhost:5000/staging/app:build-42 to localhost:5000/prod/app:1.4.2
2026/10/23 21:57:03 localhost:5000/prod/app:1.4.2: digest: sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b size: 428
2026/10/23 21:57:03 localhost:5000/prod/app:stable: digest: sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b size: 428
staging: sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b
prod:    sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b
1.4.2
stable
prod/app
staging/app

crane copy mounted the blobs (it prints a mounted blob line for each, filtered out here because they arrive in parallel, in no fixed order; a cross-repository mount means the registry links existing blobs instead of receiving them again), then wrote the same manifest. crane tag adds a second tag to the same digest without downloading anything. Rebuilding for production instead of promoting would produce a new digest, and you'd have to scan, sign and attest it all over again.

Exporting and inspecting

bash · try it yourself
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/demo/alpine:3.18.0 > /dev/null 2>&1
crane export localhost:5000/demo/alpine:3.18.0 - | tar -tf - | grep -c .
crane export localhost:5000/demo/alpine:3.18.0 - | tar -xOf - etc/alpine-release
crane export localhost:5000/demo/alpine:3.18.0 - | tar -xOf - lib/apk/db/installed | grep -A1 '^P:busybox
  

527
3.18.0
P:busybox
V:1.36.0-r9

crane export flattens the layers into one file-system tarball, which is how you check what's really in an image without running it: here the release file and the apk database entry that Syft and Grype read.

oras: artifacts that aren't images

An OCI registry stores any content-addressed blob, and since OCI 1.1 manifests have an artifactType field. oras push uploads files as an artifact:

bash · try it yourself
mkdir rel && cd rel
printf 'name: shop-web\nversion: 1.4.2\n' > release.yaml
syft scan /opt/samples/node-app -q -o cyclonedx-json=sbom.cdx.json
oras push --plain-http localhost:5000/shop/release-meta:1.4.2 \
  --artifact-type application/vnd.example.release.v1 \
  release.yaml:application/yaml sbom.cdx.json:application/vnd.cyclonedx+json > /dev/null
oras manifest fetch --plain-http localhost:5000/shop/release-meta:1.4.2 \
  | jq '{artifactType, config: .config.mediaType, layers: [.layers[] | {mediaType, title: .annotations["org.opencontainers.image.title"]}]}'
mkdir out && cd out
oras pull --plain-http localhost:5000/shop/release-meta:1.4.2 > /dev/null && ls
{
  "artifactType": "application/vnd.example.release.v1",
  "config": "application/vnd.oci.empty.v1+json",
  "layers": [
    {
      "mediaType": "application/yaml",
      "title": "release.yaml"
    },
    {
      "mediaType": "application/vnd.cyclonedx+json",
      "title": "sbom.cdx.json"
    }
  ]
}
release.yaml
sbom.cdx.json

The artifact's config is the empty descriptor (application/vnd.oci.empty.v1+json): there's no image config, because nothing will ever run this. The registry doesn't care; it stores manifests and blobs.

Attaching to an image: referrers

The more useful pattern is to attach artifacts to an image digest. The attached manifest has a subject field pointing at the image, and the registry's referrers API (GET /v2/<repo>/referrers/<digest>, OCI Distribution 1.1) lists everything that points at a digest. Registries without that API get a fallback: a tag named after the digest (sha256-<hex>) holding an index of referrers.

bash · try it yourself
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
syft scan registry:localhost:5000/shop/app:1.4.2 -q -o spdx-json=sbom.spdx.json
oras attach --plain-http --artifact-type application/spdx+json localhost:5000/shop/app:1.4.2 sbom.spdx.json > /dev/null
oras discover --plain-http --format json localhost:5000/shop/app:1.4.2 \
  | jq -r '.referrers[] | "\(.artifactType)  \(.digest[0:19])…"'
SBOM=$(oras discover --plain-http --format json localhost:5000/shop/app:1.4.2 | jq -r '.referrers[0].digest')
oras manifest fetch --plain-http localhost:5000/shop/app@$SBOM | jq -r '"subject: \(.subject.digest)"'
echo "image:   $(crane digest localhost:5000/shop/app:1.4.2)"
application/spdx+json  sha256:17b04cdbdac3…
subject: sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b
image:   sha256:f04ffda0b1406b530a735ae8676c9d6fa527618e842cc66b1bc09ae4dbd44e0b

This is the storage model cosign uses for signatures and attestations (next section): metadata lives next to the image, linked by digest, and travels with it when you copy the image together with its referrers (oras cp -r). Note what it is not: an unsigned attached SBOM is just a file anyone with push rights could have attached. Signing it is the subject of the next section.

Test yourself

Why promote with crane copy instead of rebuilding the image for production?

  1. crane copy compresses better
  2. It keeps the exact digest, so scans, signatures and attestations stay valid
  3. Rebuilding is not allowed
  4. crane copy changes the tag history

What links an attached SBOM to the image it describes in OCI 1.1?

  1. The tag name
  2. The attached manifest's subject field, which holds the image digest
  3. The file name
  4. A label in the image config

Which flag does oras need to talk to the local registry on localhost:5000?

  1. --insecure-ignore-tlog
  2. --plain-http
  3. --allow-http
  4. none