Dockerfile文档指出,有可能--platform在FROM指令中传递选项,如下所示:
FROM [--platform=<platform>] <image> [AS <name>]
Run Code Online (Sandbox Code Playgroud)
在我的 dockerfile 中,我有以下语句:
ARG arch
FROM --platform linux/${arch} bounz/hgbe.base
Run Code Online (Sandbox Code Playgroud)
其中bounz/hgbe.baseimage 有两个 os/arch 变体:linux/amd64和linux/arm/v7.
但是尝试使用此 dockerfile 构建图像时出现错误:
$ docker build -f hgbe.dockerfile --build-arg arch=amd64 -t bounz/hgbetest:amd64-0.1 .
Sending build context to Docker daemon 12.29kB
Error response from daemon: Dockerfile parse error line 2: FROM requires either one or three arguments
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?如果使用构建,有没有办法引用基础镜像的特定平台docker buildx?