Problem with intermediate Image in docker build for varying Architectures with same Base Image

未关闭
#13,681 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
docker, python

调研方向

未指定源文件或测试。首先重现 issue 中描述的并发 linux/arm/v7 和 linux/amd64 Docker 构建命令,然后检查 Docker 对中间镜像的处理,关注特定于平台的引用。只有提供了经过文档记录和验证的 workaround 或 fix,能够防止并发构建选择错误平台的镜像,才算完成。

由索引模型根据 Issue 内容生成。

描述

area/build lifecycle/frozen

In my system, I need to create a large number of images for different devices with different architectures. For this, I have a pipeline that creates multiple images using Docker in Docker, all based on one Python:3.8 image, but for different architectures. In the Docker file, I specify the base image in general:

FROM python:3.8

In the build command, I specify the architecture of the particular device:

docker build --platform linux/arm/v7 --force-rm -t localhost:5000/ImageName

docker build --platform linux/amd64 --force-rm -t localhost:5000/ImageName

The problem I'm facing at the moment is that the Docker host gets confused with the images when the pipeline triggers both or more builds at the same time. Docker doesn't seem to be able to store intermediate images for different architectures because they only differ in digest and identical tags are overwritten. For this reason, docker only seems to select the intermediate image by the name and tag and not by the sha265: that matches the architecture. This results in the following error:

failed to get destination image "sha256:4d470a81cd7a4eb2a886d8d6ca7848d66f711ea2d44375f4ab10a97c42c1adf3": image with reference sha256: 4d470a81cd7a4eb2a886d8d6ca7848d66f711ea2d44375f4ab10a97c42c1adf3 was found but does not match the specified platform: wanted linux/arm/v7, actual: linux/amd64

Also the --force-rm option in the build command does not work here, because the deletion is done after the build process is finished. I also don't want to declare the images with @sha in the dockerfile, because the identical code should be used on different devices.

What is the best way to work around or solve this problem?

主要语言
Markdown
星标
4.7k
派生
8.5k
平均合并
2 天 8 小时
30 天内合并 PR
129

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

docker/docs 的其他 Issue

查看 docker/docs 的全部 Issue

相似的 Issue

更多 Build System Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。