I ran into this issue when following the instructions in ci/README.md
for running CI locally.
Newer versions of docker require a --platform
argument when building from a platform-specific image that differs from the host platform, I’m not sure when this change took place, but trying to build any of the cross-platform CI images on Docker 27.5.0 fails in the following manner:
0$ # From ci/README.md
1$ env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'
2WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
3Creating docker.io/arm64v8/debian:bookworm container to run in
4+ docker build --file $BITCOIN_SRC/ci/test_imagefile --build-arg CI_IMAGE_NAME_TAG=docker.io/arm64v8/debian:bookworm --build-arg FILE_ENV=./ci/test/00_setup_env_arm.sh --label=bitcoin-ci-test --tag=ci_arm_linux $BITCOIN_SRC
5[+] Building 0.6s (2/2) FINISHED docker:default
6 => [internal] load build definition from test_imagefile 0.0s
7 => => transferring dockerfile: 600B 0.0s
8 => WARN: InvalidDefaultArgInFrom: Default value for ARG ${CI_IMAGE_NAME_TAG} results in empty or invalid base image name (line 8) 0.0s
9 => ERROR [internal] load metadata for docker.io/arm64v8/debian:bookworm 0.5s
10------
11 > [internal] load metadata for docker.io/arm64v8/debian:bookworm:
12------
13
14 1 warning found (use docker --debug to expand):
15 - InvalidDefaultArgInFrom: Default value for ARG ${CI_IMAGE_NAME_TAG} results in empty or invalid base image name (line 8)
16test_imagefile:8
17--------------------
18 6 |
19 7 | ARG CI_IMAGE_NAME_TAG
20 8 | >>> FROM ${CI_IMAGE_NAME_TAG}
21 9 |
22 10 | ARG FILE_ENV
23--------------------
24ERROR: failed to solve: docker.io/arm64v8/debian:bookworm: failed to resolve source metadata for docker.io/arm64v8/debian:bookworm: no match for platform in manifest: not found
This branch fixes this by setting the --platform
argument of docker build
and docker run
with an environment variable CI_IMAGE_PLATFORM
for each platform specific job, and linux/{$cpuarch}
for any native jobs.
Thi
Steps to reproduce
- Install relevant dependencies, on Ubuntu:
0sudo apt install bash docker.io python3 qemu-user-static
- Run one of the platform-specific CI images, e.g.:
0env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'