Skip to content

adding --zip/-O flag#28421

Draft
MatthewFletcher wants to merge 1 commit intocontainers:mainfrom
MatthewFletcher:main
Draft

adding --zip/-O flag#28421
MatthewFletcher wants to merge 1 commit intocontainers:mainfrom
MatthewFletcher:main

Conversation

@MatthewFletcher
Copy link
Copy Markdown

This is my first Pull Request to a larger project, so please let me know if I'm doing something incorrect!

Fixes #28420

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

podman save now allows for the user to use --zip to directly write to a .tar.gz file instead of having to pipe this into gzip.

Before:

$ podman save imagename:1 | gzip > outfile.tar.gz

Now:

$ podman save --zip imagename:1 > outfile.tar.gz 

(Working on adding a feature to auto-name the output file)


@MatthewFletcher MatthewFletcher marked this pull request as draft March 31, 2026 20:43
@MatthewFletcher MatthewFletcher changed the title adding --zip flag adding --zip/-O flag Mar 31, 2026

// ImageSaveOptions provide options for saving images.
type ImageSaveOptions struct {
//
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed

succeeded = false
)
// If --zip is used, we need to manually create a writer that gzips the content.
if saveOpts.Zip {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be integrated with the handling of the output flag - right now it feels like it duplicates a lot of that

Copy link
Copy Markdown
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a proper review but design wise I am not sure why we would call this --zip when it uses gzip. Also generally speaking I am not sure we would want lock us into a specific format like that. Other commands support --compression-format so that seem like a better option to be consistent and support multiple formats.

Then the other thing implementing this here on the client side via pipe adds exactly nothing over just having the user pipe it themselves performance wise so IMO like that there is no benefit on doing this at all.

Instead it would be better IMO to have this compression done server side so in case of podman-remote so we do not have to transfer everything uncompressed. And it would give HTTP API users the option to use it as well. Also when we do it at the source we can directly compress without copying the full stream again through the pipes

@MatthewFletcher
Copy link
Copy Markdown
Author

Part of opening this was to start a discussion on the feasibility of a feature like this. My code in my MR is a proof of concept and I'm absolutely open to ideas on how to make it more compatible with the rest of podman.

This is also my first contribution to a larger project so I'm still learning my way around this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add podman save --zip/-O

3 participants