docker / docker/docs

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

Open
#13,681 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/build lifecycle/frozen
Dominant language
Markdown
Stars
4.7k
Forks
8.5k
Avg merge
2d 18h
Merged PRs (30d)
108

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by reproducing the concurrent linux/arm/v7 and linux/amd64 docker build commands described in the issue, then inspect Docker's intermediate-image handling for platform-specific references. Done would require a documented, verified workaround or fix that prevents the concurrent builds from selecting an image for the wrong platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
build-system, devops
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.