Skip to main content
Explicit --platform on FROM does not match what the registry provides.

Description

When a FROM instruction uses an explicit --platform flag, this rule queries the container registry to verify that the requested platform is actually available for the specified image. This catches provable mismatches before they fail at build time. Unlike buildkit/InvalidBaseImagePlatform, this rule:
  • Only fires when --platform is explicitly set on the FROM instruction
  • Never compares against the host platform, so results are deterministic across machines
  • Skips automatic build args ($BUILDPLATFORM, $TARGETPLATFORM, etc.) which are dynamic

When it fires

Examples

Bad

Good

Relationship to other rules

  • buildkit/InvalidBaseImagePlatform (default: Off) — the BuildKit rule compares against the host platform even without --platform, producing non-deterministic results. This rule supersedes it with a stricter, deterministic approach.
  • buildkit/FromPlatformFlagConstDisallowed (default: Off) — the BuildKit rule warns on any constant --platform value. This is too strict: hardcoded --platform is legitimate for ARM-only services, Windows containers, and cross-compilation. The new rule validates the platform against the registry instead of discouraging it.