Skip to content

Conversation

@dcantah
Copy link
Contributor

@dcantah dcantah commented Jul 8, 2025

Fixes #231

--platform is useful as it's what most folks are used to from other container tools. We support two separate flags today that when combined (--os and --arch) do essentially the same thing, but this is a combined single string form.

@tamird
Copy link

tamird commented Jul 10, 2025

Will this also work with container build?

@dcantah
Copy link
Contributor Author

dcantah commented Jul 10, 2025

@tamird In it's current state here no, but it's trivial to add support if we want. My team is currently debating whether we want this in general though, so we'll see 😬. If they do want this flag I'll add to build as well.

@tamird
Copy link

tamird commented Jul 10, 2025

Sounds good. More broadly, do you folks care about compatibility with docker's porcelain?

@dcantah
Copy link
Contributor Author

dcantah commented Jul 11, 2025

@tamird It depends. We'd like to not be beholden to the UX of other tools, but I'd say we'd take any suggestions on a case by case basis if we think it's a good idea. Do you have any things you'd like to see besides --platform as an example?

@tamird
Copy link

tamird commented Jul 14, 2025

@dcantah nah, currently this is the main one I need. It's a bummer that --os and --arch are not accepted by docker. This makes it difficult to use container as a drop-in replacement the way I'd have liked.

Copy link
Contributor

@jglogan jglogan left a comment

Choose a reason for hiding this comment

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

Before we merge anything, let's discuss what needs to be in this PR if we're going to support os, arch, and platform.

@jglogan
Copy link
Contributor

jglogan commented Jul 16, 2025

Let's not take a scattershot approach to this. With the change this is where we are:

  • container create and container run support --os, --arch, and --platform
  • container build supports --os and --arch
  • ``container image pull, container image push`, and `container image save` support `--platform`

This PR should bring these commands (and any others that deal in platform specification) into harmony, and we should have sane input validation to ensure that the CLI rejects invalid or ambiguous combinations with clear error messages.

I think that --platform makes sense because it not only helps with tooling compatibility (the reason for the ask in the first place), but it also covers the relatively rare case where the user needs to specify a variant.

@jglogan jglogan added the next Items in scope for the next few milestones label Jul 16, 2025
@jglogan jglogan added this to the 2025-08 milestone Jul 16, 2025
@jglogan jglogan removed the next Items in scope for the next few milestones label Jul 16, 2025
@jglogan jglogan removed this from the 2025-08 milestone Jul 16, 2025
@dcantah
Copy link
Contributor Author

dcantah commented Jul 16, 2025

Ack, will amend this Thursday

Fixes apple#231

--platform is useful as it's what most folks are used to
from other container tools. We support two separate flags today
that when combined (--os and --arch) do essentially the same thing,
but this is a combined single string form.
@dcantah dcantah marked this pull request as draft July 19, 2025 11:33
@tamird
Copy link

tamird commented Jul 19, 2025

Another thing to mention about the --platform flag is that in other tools it is used to build multiarch images.

It would be great to have support for that here, too.

@dcantah
Copy link
Contributor Author

dcantah commented Jul 19, 2025

@tamird Yep. I think it's worthwhile to have it on build/pull/create/run.

@tamird
Copy link

tamird commented Jul 21, 2025

@dcantah just to clarify further: in order to build multiarch images you pass a comma-separate list of platforms as the value of --platform e.g. --platform linux/amd64,linux/arm64.

@dcantah
Copy link
Contributor Author

dcantah commented Jul 21, 2025

@tamird Yep. It's tricky as I don't believe the argument parser we use will give us that by default. I'll have to write some extra glue.

@dcantah
Copy link
Contributor Author

dcantah commented Aug 26, 2025

I keep trying to find time to update this but to no avail. @jglogan may take a stab at it

@egernst
Copy link
Contributor

egernst commented Aug 27, 2025

I'll go ahead and close this one since we have this addressed in #545. Thanks Danny.

@egernst egernst closed this Aug 27, 2025
jglogan added a commit that referenced this pull request Aug 27, 2025
- Fixes #231.
- Extends #313 (@dcantah) so that all of `container create`, `container
run`, `container build`, `container image pull`, and `container image
save` accept the three options.
- `container build` now processes comma-separated lists for
`--platform`, `--arch`, and `--os`. It first checks `--platform`,
assembling the union of all platform values. If that set is non-empty,
the builder builds the values in the set. Otherwise, the set consists of
all combinations of the specified architecture and os values, finally
defaulting to `linux` and the host architecture if no options are
provided.
- All other commands work accept a single platform, preferring the
`--platform` option over `--arch` and `--os` when both are specified.
`--os` defaults to `linux`, and `--arch` defaults to the host
architecture.
- Clarify help messages and present the args in consistent order, with
platform first since it takes precedence if present.
- Deduplicate redundant platform options for `container build`.
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.

[Request]: container run/container create should support a --platform=<OS>/<ARCH> flag

4 participants