RedundantTargetPlatform

输出

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
© . This site is unofficial and not affiliated with Kubernetes or Docker Inc.