Skip to content

[Bug]: container image save appends image references to stdout archive #1801

Closed

Description

@0verflowme

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

  1. Build or use container from current main.

  2. Save an image without --output, redirecting stdout to a tar file:

    container image save alpine:latest > alpine.tar
  3. Inspect the resulting archive with a tar/OCI consumer that expects the stream to end at the tar EOF markers.

The current implementation writes the archive bytes to stdout, then prints each saved image reference to stdout afterward:

  • Sources/ContainerCommands/Image/ImageSave.swift, lines 132-137: writes tar chunks to FileHandle.standardOutput
  • Sources/ContainerCommands/Image/ImageSave.swift, lines 141-144: calls print(reference) after the stdout archive path completes

Problem description

When container image save is used without --output, stdout is the archive stream. The command should emit only archive bytes on stdout so shell redirection and pipelines produce a valid OCI-compatible tar archive.

Currently, after writing the tar data to stdout, the command prints image references to stdout. That appends text bytes after the archive stream, so a command such as:

container image save alpine:latest > alpine.tar

creates an archive with trailing non-archive output. container image load may tolerate that trailing data, so the existing stdin/stdout integration test can pass while other tar or OCI tooling rejects or warns about the archive. Status/reference output for the stdout mode should go to stderr/logging, or be suppressed when stdout is carrying the archive.

Environment

- OS: macOS 26.5.1 (25F80)
- Xcode: Full Xcode is not selected locally; active developer directory is /Library/Developer/CommandLineTools. Swift reports Apple Swift 6.3.2 targeting arm64-apple-macosx26.0.
- Container: container CLI version 1.0.0-15-g1d70dd6 (build: debug, commit: 1d70dd6)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added a commit that references this issue on Jun 26, 2026
    aa7fef3
  2. added a commit that references this issue on Jul 16, 2026
    3158639
  3. added a commit that references this issue on Aug 28, 2026
    9106f4c
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