冗余目标平台

输出

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

描述

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

示例

❌ 错误:这种使用 --platform 的方式是多余的,因为 $TARGETPLATFORM 是默认值。

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

✅ 好:省略 --platform 参数。

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