Skip to content

RFC: design for pulling a single blob to stdout (oras pull --output -) #2197

Open

Description

@TerryHowe

Summary

Proposed design for streaming an artifact's content to stdout with oras pull --output -, so it can be piped:

$ oras pull --output - localhost:5000/cache:v1 | tar -xz

#346 has the use case and four years of good discussion, but the open design questions are scattered across ~24 comments and it is still unresolved. This issue collects them and proposes one approach so the design can be agreed before anyone implements it (as requested in #346 (comment)).

Scope is the pull side only. Streaming a push from stdin is #1200.

Questions raised so far in #346

  1. What happens with more than one layer? (@shizhMSFT, @qweeah — asked repeatedly and never settled.) Suggestions so far: error out, or synthesize a tar.
  2. How does the caller know what it is about to receive? (@DerRockWolf, most recent comment.) Piping a JSON blob into tar should fail with an ORAS error, not a downstream crash.
  3. How does status output stay out of the stream? Progress bars and metadata must not land in stdout.

Today the workaround is two commands plus a JSON/YAML processor:

$ oras blob fetch -o - ghcr.io/foo/test@$(oras manifest fetch ghcr.io/foo/test:0.0.1 | jq -r '.layers[0].digest')

The value of --output - is doing exactly that, without needing jq and without knowing the digest.

Proposed approach

1. --output - streams exactly one blob, raw. The bytes written to stdout are byte-identical to the blob as pushed. ORAS does not repackage, concatenate, or synthesize an archive.

2. Layer selection. The candidate set is the layers oras pull would otherwise write as files: named layers, minus the empty JSON layer, minus the config (unless --config is given), minus the subject.

  • exactly one candidate → stream it
  • zero candidates → error
  • more than one candidate → error listing each candidate's title, mediaType, and digest, with a recommendation to narrow with --media-type or to pull into a directory instead

Erroring on ambiguity matches @shizhMSFT's suggestion in #346 (comment) and keeps the stream unambiguous.

3. --media-type narrows and asserts. Repeatable/comma-separated, same shape as oras manifest fetch --media-type. It restricts the candidate set, and if nothing matches, ORAS exits non-zero before writing any output:

$ oras pull --output - --media-type application/vnd.oci.image.layer.v1.tar+gzip localhost:5000/cache:v1 | tar -xz

This answers question 2 and does the selecting in question 1 with one flag.

4. stdout carries blob bytes and nothing else. All status, warnings, and metadata go to stderr, and TTY progress is disabled when --output - is used — the same DisableTTY(opts.Debug, opts.outputPath == "-") treatment oras blob fetch already applies. --format / descriptor output combined with --output - is an error, as it already is in oras blob fetch.

5. Flags that make no sense with a stream are errors, not silent no-ops: --keep-old-files, --allow-path-traversal, --config, --include-subject. --platform still applies when the reference resolves to an index.

6. Integrity has a caveat worth documenting. The blob is read through a content.VerifyReader, but the digest is only confirmed at EOF — by which time the bytes have already reached the downstream process. ORAS must exit non-zero on mismatch, and the docs should tell users to check the exit status (set -o pipefail) rather than trusting the pipe. oras blob fetch --output - has the same property today; --output - on pull should not pretend otherwise.

7. Folder artifacts stream as the archive. A layer pushed from a directory carries io.deis.oras.content.unpack; with --output - it is streamed as the tar+gzip bytes with no unpacking, since unpacking has no meaning for a stream. Worth a note on stderr and in the docs.

8. Implementation shape. This is resolve-manifest → select-layer → fetch-blob, i.e. the jq one-liner above fused into one command. It bypasses the file store entirely (file.New needs a directory), so it is a distinct path in runPull rather than a new kind of destination target.

Deliberately not proposed

Synthesizing a tar for multi-layer artifacts (the --to-stdout:tar idea in #346 (comment)). It would make ORAS emit bytes that were never pushed, invent archive layout and metadata decisions, and overlap confusingly with the file store's existing folder packing. Multi-file artifacts are already served by pulling into a directory. If demand appears later it can be added behind its own flag without changing anything above.

Open questions

  • Should selection by file name also exist (e.g. --name openshift-install-artifacts.tar.gz.enc), or is --media-type enough for now?
  • Should the manifest config be selectable for streaming, or stay behind --config?
  • Does this warrant a doc under docs/proposals/ before implementation, and is v1.4.0 the right milestone?

cc @shizhMSFT @qweeah — refs #346, #1200

Activity

  1. TerryHowe commented on Oct 22, 2026

    @TerryHowe
    MemberAuthor

    #346, the original request for oras pull --output -, was closed as a duplicate of this RFC. Its use cases and discussion remain available for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions