Skip to main content
FROM --platform flag should not use a constant value.

Tally behavior deviation

Tally disables this rule by default because hardcoding --platform is legitimate in several real-world scenarios:
  • ARM-only services. Deployments targeting AWS Graviton or other ARM-only infrastructure use FROM --platform=linux/arm64 to ensure the correct architecture regardless of where the build runs.
  • Windows containers. Windows Dockerfiles use FROM --platform=windows/amd64 mcr.microsoft.com/... to explicitly target Windows, which is necessary when the builder could be multi-platform.
  • Cross-compilation. Go and Rust projects commonly use FROM --platform=linux/amd64 golang:1.22 for a specific builder stage while the final image targets a different architecture.
Rather than discouraging constant --platform values, tally validates them against the registry with tally/platform-mismatch. This catches provable errors (image doesn’t publish the requested platform) without flagging intentional platform pinning. You can re-enable this rule via configuration if you prefer the BuildKit behavior:

Description

When the --platform flag appears with a hardcoded value, it restricts image building to a single target platform, preventing multi-platform images. The recommended strategy involves:
  • Removing FROM --platform and applying --platform at build time.
  • Substituting $BUILDPLATFORM or comparable variable expressions.
  • Naming stages to reflect platform when containing platform-specific operations.

Examples

Bad:
Good (default platform):
Good (meta variable):
Good (multi-stage build with target architecture):

Supersedes

See also