冗余目标平台

输出

Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior

描述

可以使用自定义平台作为基础镜像。默认平台与目标输出平台相同,因此将平台设置为$TARGETPLATFORM是冗余且不必要的。

示例

❌ 错误:由于$TARGETPLATFORM是默认值,因此这种--platform用法是冗余的。

FROM --platform=$TARGETPLATFORM alpine AS builder
RUN apk add --no-cache git

✅ 正确:省略--platform参数。

FROM alpine AS builder
RUN apk add --no-cache git