我这里有一个非常简单的Dockerfile:
FROM --platform=linux/arm64 nvidia/cuda:10.1-cudnn7-runtime我希望构建这样的东西会失败-- nvidia/cuda:10.1-cudnn7-runtime没有一个arm64图像。相反,它似乎是透明地拉出图像的amd64版本而不是.?我的构建命令是:
docker buildx build -f ./docker/Dockerfile.wtf -t asdf --platform linux/arm64 --load --no-cache .当我在我的amd64主机上运行它时,它会抱怨不匹配,但仍然运行得很好:
▶ docker run --rm -it asdf uname -a
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested
Linux 1457f3c2456a 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux如果请求的平台不可用,我如何告诉Docker/buildkit失败?为什么在没有arm64映像可用的情况下,它还是成功了?
发布于 2022-07-13 20:15:57
来自文档上的FROM --platform选项:
可选的
--platform标志可用于指定映像的平台,以防FROM引用多平台映像。
您所引用的图像不是多平台映像:
$ docker buildx imagetools inspect nvidia/cuda:10.1-cudnn7-runtime
Name: docker.io/nvidia/cuda:10.1-cudnn7-runtime
MediaType: application/vnd.docker.distribution.manifest.v2+json
Digest: sha256:faa4157b1a08e88ec53a3b549f6d229a9e9c0071250a23382bac1f2dd3ddca8c因此,对接者将按原样使用图像,而无需从多平台映像中选择请求的平台(因为图像不是多平台的)。
要使此失败,您需要创建一个基本映像,它是一个包含列表中的单个平台的多平台清单,然后在尝试使用不同的平台时会看到失败。
https://stackoverflow.com/questions/72971504
复制相似问题