Skip to content

engine: add platform field to EngineConfig#2542

Closed
TrevorBurnham wants to merge 1 commit intocontainers:mainfrom
TrevorBurnham:add-engine-platform-config
Closed

engine: add platform field to EngineConfig#2542
TrevorBurnham wants to merge 1 commit intocontainers:mainfrom
TrevorBurnham:add-engine-platform-config

Conversation

@TrevorBurnham
Copy link

Issue: containers/podman#25641

This PR adds a new platform option to the [engine] section of containers.conf:

[engine]
platform = "linux/amd64"

This allows users to set a default platform (os/arch or os/arch/variant) for image operations such as pull, build, run, and create.

Why

Users currently have no way to globally default to a different platform. This forces workarounds for tools that don't expose --platform flags. Docker supports this via DOCKER_DEFAULT_PLATFORM, but Podman has no equivalent config or env var.

This PR provides the containers/common foundation. A follow-up PR in containers/podman will wire this into pull/build/run/create and add DOCKER_DEFAULT_PLATFORM env var support for Docker compatibility.

Changes

  • pkg/config/config.go: Added Platform field to EngineConfig with toml:"platform" tag
  • pkg/config/config.go: Added PlatformComponents() method to parse the field into os, arch, variant
  • pkg/config/config.go: Added validatePlatform() and wired it into EngineConfig.Validate()
  • docs/containers.conf.5.md: Documented the new platform option in the [engine] table
  • pkg/config/config_test.go: Added tests for valid/invalid platforms, empty default, and component parsing
  • pkg/config/testdata/containers_override.conf: Added platform to the override test fixture

Validation

The platform string is validated on config load:

  • Must be os/arch or os/arch/variant (e.g., linux/amd64, linux/arm64/v8)
  • Empty string is valid (means "use host platform")
  • Rejects single-component values (linux), trailing slashes (linux/amd64/), and missing components (/amd64)

Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
@github-actions
Copy link

This repository has been migrated to https://github.com/containers/container-libs. Please open your PR there.

@TrevorBurnham
Copy link
Author

Whoops! Opened as containers/container-libs#669.

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.

1 participant