Skip to content

Conversation

@Sunsvea
Copy link

@Sunsvea Sunsvea commented Aug 6, 2025

This change addresses issue #83 by modifying the default behavior of container images pull to automatically select the current platform when no --platform flag is specified.

This reduces bandwidth consumption by up to ~95% (from ~8GB to ~350MB for multi-platform images like python).

What changed

  • Modified ImagePull.swift to default to Platform.current instead of pulling all platforms
  • Added test coverage with testPullDefaultPlatform()
  • Maintains backward compatibility with --platform flag

Why this change

Users reported excessive bandwidth usage when pulling container images, as the default behavior downloads all available platforms. This particularly impacts users on limited connections and increases registry load unnecessarily.

Testing

  • New test confirms single-platform pulling behavior
  • Manual tests show bandwidth reduction from ~8GB to ~350MB for multi-arch images
  • Backward compatibility verified with --platform flag

Impact

  • Faster pull times for end users
  • Reduced load on container registries
  • Zero breaking changes to existing workflows

Sunsvea added 2 commits August 6, 2025 11:29
- Change ImagePull CLI to default to Platform.current when no --platform specified
- Reduces downloads from ~8GB to ~350MB for multi-arch images
- Maintains backward compatibility with explicit --platform flag
- Add test to verify default platform behavior
- Use busybox instead of alpine to avoid cache conflicts with other tests
- Test now properly verifies single-platform pulling behavior
@dcantah
Copy link
Member

dcantah commented Aug 6, 2025

cc @adityaramani as this behavior was chosen for a reason

@adityaramani
Copy link
Contributor

adityaramani commented Aug 6, 2025

The reason for pulling (and pushing) all platforms by default is that - if a user decided to do something like the following, and foo is a multi platform image

container image pull foo
container image tag foo bar
container image push bar

We should be keeping the sha of the index the same for the image we are pushing out, which would mean that we have to push out all the layers / sub-layers referenced in the index, which would include all the platforms. And to do that, we need to have all the layers present on disk

That being said - we have quite a few issues around the same area, and are open to changing the default behavior to work with only the current platform.

The changes required for this would be

  • Change the default for pull / push commands to be the current platform (you have done this for pull)
  • Add in a flag / a way for the user to specify that they want to pull / push all platforms. Maybe a --all-platforms flag?

Im not sure if we should have a different default for pull (current platform only) vs push (all platforms), but if we do we'd need some error handling and think about the UX

@Sunsvea
Copy link
Author

Sunsvea commented Aug 7, 2025

The reason for pulling (and pushing) all platforms by default is that - if a user decided to do something like the following, and foo is a multi platform image

container image pull foo
container image tag foo bar
container image push bar

We should be keeping the sha of the index the same for the image we are pushing out, which would mean that we have to push out all the layers / sub-layers referenced in the index, which would include all the platforms. And to do that, we need to have all the layers present on disk

That being said - we have quite a few issues around the same area, and are open to changing the default behavior to work with only the current platform.

The changes required for this would be

* Change the default for pull / push commands to be the current platform (you have done this for pull)

* Add in a flag / a way for the user to specify that they want to pull / push all platforms. Maybe a `--all-platforms` flag?

Im not sure if we should have a different default for pull (current platform only) vs push (all platforms), but if we do we'd need some error handling and think about the UX

@adityaramani I admit I like the sound of a 'smart' push workflow that cares about the local image state (i.e. push all platforms if local image has multiple platforms) but I feel it would introduce too much ambiguity.

I would lean toward a coherent workflow for both push/pull such as:

  1. pull current platform by default
  2. push current platform by default
  3. use --all-platforms for both when doing multi-arch workflows
  4. likewise use --platform=arm64 when pulling or pushing to specific platforms.

Lastly, this would mean that we're updating the default behavior for push/pull. We'd need to consider how we'll communicate the change to anyone who's currently using this tool...

I'd be keen to hear some feedback from others.

@bennettp123
Copy link

Another option might be to allow people to opt in (or out) of the new behaviour using something like

defaults write com.apple.container.defaults push.platforms <platforms>
defaults write com.apple.container.defaults pull.platforms <platforms>

@Mcrich23
Copy link
Contributor

Mcrich23 commented Sep 19, 2025

Hey! So sorry, but in an effort to make plugin development more possible #603 and #635 have lead to the CLI folder being renamed to ContainerCommands and that will impact the merging of your pull request. Just an FYI, so you understand the issue when you are resolving conflicts.

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.

6 participants