Skip to content

Support default platform via containers.conf and CONTAINER_DEFAULT_PLATFORM#28154

Draft
TrevorBurnham wants to merge 1 commit intocontainers:mainfrom
TrevorBurnham:support-default-platform
Draft

Support default platform via containers.conf and CONTAINER_DEFAULT_PLATFORM#28154
TrevorBurnham wants to merge 1 commit intocontainers:mainfrom
TrevorBurnham:support-default-platform

Conversation

@TrevorBurnham
Copy link

@TrevorBurnham TrevorBurnham commented Feb 25, 2026

Depends on: containers/container-libs#669

Closes: #25641

This PR adds support for setting a default platform for image operations (pull, build, create, run) without requiring --platform on every command.

The default platform is resolved in the following priority order:

  1. Explicit --platform (or --arch/--os) flag
  2. CONTAINER_DEFAULT_PLATFORM environment variable (new)
  3. containers.conf [engine] platform setting (new)
  4. Host's native OS/architecture

Checklist

  • 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?

Yes:

Podman now supports setting a default platform for image operations via the `platform` option in `containers.conf` or the `CONTAINER_DEFAULT_PLATFORM` environment variable. ([#25641](https://github.com/containers/podman/issues/25641)).

@TrevorBurnham TrevorBurnham force-pushed the support-default-platform branch from 27ec27b to 787b31a Compare February 25, 2026 19:58
@TrevorBurnham TrevorBurnham marked this pull request as draft February 25, 2026 20:11
Copy link
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.

see https://github.com/containers/container-libs/blob/main/CONTRIBUTING_GO.md#testing-changes-in-a-dependent-repository

How to properly update and test changes here so ci can run.

Overall I do not think we should use DOCKER_DEFAULT_PLATFORM at all. If we really need and env it should be a different one IMO

And now regarding the client vs server side and code deduplication I think we might be able best to handle this once on the common package in the libimage runtime in the pull function.

I guess we would still need to handle the build part though.

// If no explicit --platform, --os, --arch, or --variant was given,
// fall back to DOCKER_DEFAULT_PLATFORM env var, then containers.conf platform.
if !c.Flag("platform").Changed && !c.Flag("os").Changed && !c.Flag("arch").Changed && !c.Flag("variant").Changed {
defOS, defArch, defVariant, pErr := util.DefaultPlatform(podmanConfig.ContainersConfDefaultsRO.Engine.Platform)
Copy link
Member

Choose a reason for hiding this comment

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

the handling of such containers.conf fields should not be on the client side generally, I know we have been very inconsistent but I will try to enforce that for all new code
In general the code like that is wrong because something like "local" would be resolved on client side while the server can have a different arch.

Copy link
Author

Choose a reason for hiding this comment

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

Updated.

@TrevorBurnham TrevorBurnham force-pushed the support-default-platform branch 3 times, most recently from 8fc6215 to fcf76b4 Compare February 26, 2026 20:30
@TrevorBurnham
Copy link
Author

How to properly update and test changes here so ci can run.

Done, thanks!

Overall I do not think we should use DOCKER_DEFAULT_PLATFORM at all. If we really need and env it should be a different one IMO…

Supporting an env var strikes me as the most straightforward way to solve the problem described on #25641, where a user wants to specify the platform but doesn't have the ability to pass a --platform param directly.

Personally I really like the idea of supporting DOCKER_DEFAULT_PLATFORM for compatibility, the same way that Podman supports DOCKER_HOST and DOCKER_CONFIG.

@TrevorBurnham TrevorBurnham force-pushed the support-default-platform branch 2 times, most recently from 3a70883 to 9f490e3 Compare February 27, 2026 18:56
@Luap99
Copy link
Member

Luap99 commented Mar 4, 2026

Personally I really like the idea of supporting DOCKER_DEFAULT_PLATFORM for compatibility, the same way that Podman supports DOCKER_HOST and DOCKER_CONFIG.

I dont see where DOCKER_HOST is used? It is being set by clients that like to talk to our socket but podman itself does not need to read it, i.e. having that set will not make podman-remote talk to that endpoint at all. WE use CONTAINER_HOST instead.

DOCKER_CONFIG is used by our code but IMO there is no downside to reading that file AFAICT, DOCKER_DEFAULT_PLATFORM would actively alter the podman behavior and I Don;t like that as people can use podman and docker in parallel if they want so using one env for both does not seem right.

If people want an env I am fine adding a new one but I do not want to use a DOCKER_ one as we do now own that.

…ATFORM

Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
@TrevorBurnham TrevorBurnham force-pushed the support-default-platform branch from 9f490e3 to 90deceb Compare March 5, 2026 18:44
@TrevorBurnham TrevorBurnham changed the title Support default platform via containers.conf and DOCKER_DEFAULT_PLATFORM Support default platform via containers.conf and CONTAINER_DEFAULT_PLATFORM Mar 5, 2026
@TrevorBurnham
Copy link
Author

Got it. I saw references to DOCKER_HOST and DOCKER_CONFIG in the codebase and thought those were being used for drop-in compatibility; I was mistaken.

I've rebased the PR branch and updated it to use CONTAINER_DEFAULT_PLATFORM instead of DOCKER_DEFAULT_PLATFORM.

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

Labels

kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set default architecture (without passing --platform)?

3 participants