FromPlatformFlagConstDisallowed
Output
FROM --platform flag should not use constant value "linux/amd64"Description
Specifying --platform in the Dockerfile FROM instruction forces the image to build on only one target platform. This prevents building a multi-platform image from this Dockerfile and you must build on the same platform as specified in --platform.
The recommended approach is to:
- Omit
FROM --platformin the Dockerfile and use the--platformargument on the command line. - Use
$BUILDPLATFORMor some other combination of variables for the--platformargument. - Stage name should include the platform, OS, or architecture name to indicate that it only contains platform-specific instructions.
Examples
❌ Bad: using a constant argument for --platform
FROM --platform=linux/amd64 alpine AS base
RUN apk add --no-cache git✅ Good: using the default platform
FROM alpine AS base
RUN apk add --no-cache git✅ Good: using a meta variable
FROM --platform=${BUILDPLATFORM} alpine AS base
RUN apk add --no-cache git✅ Good: used in a multi-stage build with a target architecture
FROM --platform=linux/amd64 alpine AS build_amd64
...
FROM --platform=linux/arm64 alpine AS build_arm64
...
FROM build_${TARGETARCH} AS build
...
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
