[Bug]: MalformedChunkCodingException since Update to 1.21.4/2.0.3
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先,使用 PostgreSQLContainer、PullAlwaysPolicy 以及报告中的 Windows Docker 配置复现该故障。阅读失败的环境检查附近的 DockerClientProviderStrategy 和 NpipeSocketClientProviderStrategy,并检查 MalformedChunkCodingException 的路径。完成的标准是,报告中的配置能够在不出现 MalformedChunkCodingException 错误的情况下启动容器。
由索引模型根据 Issue 内容生成。
描述
Module
Core
Testcontainers version
1.21.4, 2.0.3
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host Arch
X64
Docker version
Client:
Version: 29.0.2-rd
API version: 1.51 (downgraded from 1.52)
Go version: go1.25.4
Git commit: 5a2d7eb
Built: Tue Nov 18 23:34:16 2025
OS/Arch: windows/amd64
Context: default
Server:
Engine:
Version: 28.3.3
API version: 1.51 (minimum version 1.24)
Go version: go1.24.8
Git commit: bea959c7b793b32a893820b97c4eadc7c87fabb0
Built: Sun Oct 12 08:01:14 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.1.5
GitCommit: fcd43222d6b07379a4be9786bda52438f0dd16a1
runc:
Version: 1.3.3
GitCommit: d842d7719497cc3b774fd71620278ac9e17710e0
docker-init:
Version: 0.19.0
GitCommit:
What happened?
Hi,
I described the problem in a comment in #11254 but given the nature of it, I think it warrants its own issue ticket.
Since updating to Testcontainers 1.21.4/2.0.3 we are occasionally encountering an exception:
NpipeSocketClientProviderStrategy: failed with exception RuntimeException (com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.MalformedChunkCodingException: Bad chunk header: ). Root cause MalformedChunkCodingException (Bad chunk header: )
I can reproduce it with something simple as the following code. For some reason it becomes more probable when running in debug mode.
try ( final PostgreSQLContainer<?> container = new PostgreSQLContainer<>( "postgres:14" ) ) {
container.start( );
}
I use a custom policy to make sure that the image is always pulled.
public final class PullAlwaysPolicy implements ImagePullPolicy {
@Override
public boolean shouldPull( final DockerImageName imageName ) {
return true;
}
}
Thank you and best regards
Nils
Relevant log output
Feb. 02, 2026 10:17:54 AM org.testcontainers.images.PullPolicy defaultPolicy
INFORMATION: Found configured Image Pull Policy: class com.example.demo.PullAlwaysPolicy
Feb. 02, 2026 10:17:54 AM org.testcontainers.images.PullPolicy defaultPolicy
INFORMATION: Image pull policy will be performed by: com.example.demo.PullAlwaysPolicy@5d76b067
Feb. 02, 2026 10:17:54 AM org.testcontainers.utility.ImageNameSubstitutor instance
INFORMATION: Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
Feb. 02, 2026 10:17:54 AM org.testcontainers.DockerClientFactory getOrInitializeStrategy
INFORMATION: Testcontainers version: 2.0.3
Feb. 02, 2026 10:17:54 AM org.testcontainers.dockerclient.DockerClientProviderStrategy lambda$loadConfiguredStrategy$9
INFORMATION: Loaded org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
Feb. 02, 2026 10:17:55 AM org.testcontainers.dockerclient.DockerMachineClientProviderStrategy isApplicable
INFORMATION: docker-machine executable was not found on PATH ([REDACTED])
Feb. 02, 2026 10:17:55 AM org.testcontainers.dockerclient.DockerClientProviderStrategy lambda$getFirstValidStrategy$7
SCHWERWIEGEND: Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
NpipeSocketClientProviderStrategy: failed with exception RuntimeException (com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.MalformedChunkCodingException: Bad chunk header: ). Root cause MalformedChunkCodingException (Bad chunk header: )As no valid configuration was found, execution cannot continue.
See https://java.testcontainers.org/on_failure.html for more details.
Exception in thread "main" java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$7(DockerClientProviderStrategy.java:274)
at java.base/java.util.Optional.orElseThrow(Optional.java:403)
at org.testcontainers.dockerclient.DockerClientProviderStrategy.getFirstValidStrategy(DockerClientProviderStrategy.java:265)
at org.testcontainers.DockerClientFactory.getOrInitializeStrategy(DockerClientFactory.java:154)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:196)
at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:108)
at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:316)
at com.example.demo.Main.main(Main.java:9)
Additional Information
No response
- 主要语言
- Java
- 星标
- 8.7k
- 派生
- 1.9k
- 平均合并
- 17 小时 38 分钟
- 30 天内合并 PR
- 3
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testcontainers/testcontainers-java 的其他 Issue
-
[Bug]: Build fails with "Unknown cli flag: --scripts-prepend-node-path" due to outdated Spotless plugin可能已有人在做 @dhruv9b 于 35 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-java#11997 · 1 条评论 ·
维护者通常 1 天内回复
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching可能已有人在做 @zakaullah075 于 52 天前认领。 未关闭type/enhancement
难度 1/5 1 小时以内 新手友好度 85/100
testcontainers/testcontainers-java#11967 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under Linux可能已有人在做 @kdelay 于 73 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-java#11941 ·
维护者通常 1 天内回复
-
[Bug]: DockerDesktopClientProviderStrategy is always applicable可能已有人在做 @seonwooj0810 于 122 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 74/100
testcontainers/testcontainers-java#11829 · 1 条评论 ·
维护者通常 1 天内回复
-
[Enhancement]: cleanup document after removing junit4 support可能已有人在做 @SJvaca30 于 130 天前认领。 未关闭type/enhancement
难度 2/5 1-3 小时 新手友好度 65/100
testcontainers/testcontainers-java#11578 ·
维护者通常 1 天内回复
查看 testcontainers/testcontainers-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
-
area/docs
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
BoxChart rejects valid List.of data with NullPointerException可能已有人在做 @PHJ2000 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100