[Enhancement]: RemoteDockerImage silently falls back to linux/amd64 on any pull failure, leaving a wrong-architecture image on non-amd64 hosts
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 45/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- docker, java
研究方向
Start from RemoteDockerImage.pullImage in the core module, where the catch (DockerClientException | NotFoundException) block retries with withPlatform("linux/amd64"); read the surrounding tryImagePullCommand retry loop and #4290 to see why it exists. Pick the gate (daemon architecture, or a new testcontainers.properties key), then add a WARN with image name, original message, host arch and retried platform. Done means the fallback no longer fires on quota, auth or network errors or on non-arm64 hosts, with a test covering both paths.
由索引模型根據 Issue 內容生成。
描述
Module
Core
Proposal
RemoteDockerImage.pullImage(...) retries a failed pull with withPlatform("linux/amd64") for any DockerClientException or NotFoundException, on any host architecture, and logs nothing when it does. On ppc64le or s390x hosts this can leave an amd64 image under the regular tag. The default pull policy then reuses that image forever, and containers fail with exec format error.
Current behavior
Code in 2.0.5 (the fallback was introduced in 1.16.0 by #4290, "Fallback to x86 image if image pulling fails"):
private TimeLimitedLoggedPullImageResultCallback pullImage(PullImageCmd pullImageCmd, Logger logger)
throws InterruptedException {
try {
return pullImageCmd.exec(new TimeLimitedLoggedPullImageResultCallback(logger)).awaitCompletion();
} catch (DockerClientException | NotFoundException e) {
// Try to fallback to x86
return pullImageCmd
.withPlatform("linux/amd64")
.exec(new TimeLimitedLoggedPullImageResultCallback(logger))
.awaitCompletion();
}
}
Problems:
- It isn't limited to hosts where it makes sense. The intent, from the comment and the PR title, is Apple Silicon/arm64 hosts pulling x86-only images, where amd64 images run under emulation. On ppc64le or s390x there is generally no amd64 emulation, so the pulled image is unusable.
- The exceptions are too broad.
DockerClientExceptionis also what docker-java'sPullImageResultCallbackthrows for any failed pull, for exampleCould not pull image: toomanyrequests: Quota exceeded .... That is a registry or mirror quota error, unrelated to a missing platform, yet it triggers the amd64 retry. - The fallback is silent. The
catchblock logs nothing, so the original error and the platform switch are invisible, even at DEBUG. The only visible trace is the laterexec format error. - The wrong image sticks. The amd64 image is stored under the normal tag, and the default pull policy only pulls images that aren't available locally. Every later run reuses the bad image until it is removed manually. Pulling with the Docker CLI works, because it is pinned to the host platform and fails loudly.
Real-world impact
Apache Camel CI (CAMEL-26387) has ppc64le and s390x Jenkins nodes behind a registry mirror (mirror.gcr.io). The mirror intermittently returns:
toomanyrequests: Quota exceeded for quota metric 'Read requests to external upstream hosts per organization per host ...'
This mostly affects ppc64le and s390x, probably because amd64 content is usually already cached by the mirror, so the amd64 retry succeeds. Images such as postgres, redis, nats, solr, cassandra and rabbitmq ended up as amd64 on ppc64le and s390x nodes and then failed with exec format error.
Proposed improvements
Any combination of the following would help:
- Restrict the fallback by host architecture. Only fall back to
linux/amd64when the Docker daemon's architecture isarm64/aarch64. Alternatively, make it configurable, for example apull.platform.fallbackproperty intestcontainers.propertiesor an environment variable, takinglinux/amd64,none, orauto(the default). - Be more selective on the error. Fall back only when the failure indicates a missing platform in the manifest, for example
no matching manifest for linux/ppc64le in the manifest list entries. Do not fall back on quota errors (toomanyrequests), auth errors, network errors orInternalServerErrorException. Those should keep using the existing retry loop intryImagePullCommand. - Log the fallback. At
WARN, include the image name, the original exception message, the host architecture and the platform used for the retry. For example:Pulling image X failed (<message>); retrying for platform linux/amd64. This image may not run on this host (<arch>). - Optionally, verify after the fallback. If the pulled image architecture differs from the daemon's and no emulation is expected, log a warning, or fail fast with a clear message.
Workaround
- Pre-pull on the node with
docker pull --platform linux/<arch> <image>before the tests, so Testcontainers finds the image locally. - Use a custom
ImagePullPolicyregistered withpull.policy=<fully qualified class name>in atestcontainers.propertiesfile on the classpath. Apache Camel usesHostArchitectureImagePullPolicyin https://github.com/apache/camel/pull/30672. If the local image architecture differs from the host's, it logs a warning, removes the image and pulls it again. If the image is missing, it pulls it itself withwithPlatform("linux/<host arch>"), so thelinux/amd64fallback never runs. It then checks the architecture again and throwsContainerFetchExceptionon a failure or mismatch.
Environment
- Testcontainers 2.0.5 (the code is unchanged since 1.16.0 in the versions I looked at)
- docker-java 3.7.1
- Hosts: Linux ppc64le and s390x, with Docker or Podman
This issue was drafted by IBM Bob (AI assistant) on behalf of @apupier.
- 主要語言
- Java
- 星號
- 8.8k
- 分支
- 2k
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 11
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
testcontainers/testcontainers-java 的其他 Issue
-
[Bug]: WaitStrategyTarget Handles Multiple Ports Differently to Documentation可能已有人在做 @suvvvv 於 2 天前認領。 未關閉type/bug
難度 2/5 1-3 小時 新手友好度 68/100
testcontainers/testcontainers-java#12196 ·
維護者通常 1 天內回覆
-
[Bug]: DockerImageName treats uppercase registry names as repository paths可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
testcontainers/testcontainers-java#12186 · 1 則留言 ·
維護者通常 1 天內回覆
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategy可能已有人在做 @aymenjamaaoui 於 18 天前認領。 未關閉type/bug
難度 2/5 1-3 小時 新手友好度 64/100
testcontainers/testcontainers-java#12171 · 1 則留言 ·
維護者通常 1 天內回覆
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching可能已有人在做 @zakaullah075 於 111 天前認領。 未關閉type/enhancement
難度 1/5 1 小時以內 新手友好度 85/100
testcontainers/testcontainers-java#11967 · 1 則留言 ·
維護者通常 1 天內回覆
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under Linux可能已有人在做 @kdelay 於 132 天前認領。 未關閉type/bug
難度 2/5 1-3 小時 新手友好度 78/100
testcontainers/testcontainers-java#11941 ·
維護者通常 1 天內回覆
查看 testcontainers/testcontainers-java 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
good first issue help wanted
難度 2/5 1-3 小時 新手友好度 88/100
erkamyaman/rust-anything#1381 ·
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 80/100
java-native-access/jna#1757 ·