Docker 与测试容器绑定解析异常
Docker Binding parse exception with testcontainers
我想 运行 一些集成测试,其中包括使用 org.testcontainers Docker Compose 模块设置完整的环境。我是 Windows 和 Docker 测试的新手,与测试容器一样。
使用版本:
- Docker 桌面社区:2.5.0.0
- org.testcontainers:测试容器:1.15.0
- org.springframework.boot 2.3.4.
我的代码如下所示:
@ClassRule
public static DockerComposeContainer environment = new DockerComposeContainer(
new File("C:\dev\myproject\myapp\docker-compose\docker-compose.env.yml"),
new File("C:\dev\myproject\myapp\docker-compose\docker-compose.yml"))
.withExposedService("myservice_1", 9999)
.withLocalCompose(true);
我的撰写文件看起来像这样。
services:
myservice:
image: myapp/myservice:latest
hostname: myservice
volumes:
- ../volumeDir:/app/volumeDir
- ../config:/app/config
expose:
- 9999
ports:
- 9999:9999
command: -Dspring.liquibase.enabled=true
networks:
- internet
看起来像一些绑定错误,堆栈跟踪的最重要部分:
> java.lang.RuntimeException: java.lang.RuntimeException: org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.ValueInstantiationException:
> Cannot construct instance of `com.github.dockerjava.api.model.Binds`,
> problem: Error parsing Bind
> 'C:\dev\myproject\myapp\volumeDir:/app/volumeDir:rw'
> at [Source: (org.testcontainers.shaded.okio.RealBufferedSource); line: 1,
> column: 1369] (through reference chain:
> com.github.dockerjava.api.command.InspectContainerResponse["HostConfig"]->com.github.dockerjava.api.model.HostConfig["Binds"])
> at org.rnorth.ducttape.timeouts.Timeouts.callFuture(Timeouts.java:68)
> at org.rnorth.ducttape.timeouts.Timeouts.doWithTimeout(Timeouts.java:60)
> at org.testcontainers.containers.wait.strategy.WaitAllStrategy.waitUntilReady(WaitAllStrategy.java:53)
> ...
我试过把路径改成absolute,没有任何区别。您有什么想法可以使此绑定无法解析吗?
此错误是由于 Testcontainers 的当前问题以及 Windows 版本的最新 Docker。他们是 already aware of it and a fix seems close to being merged.
更新:版本 1.15.1 现已可用,修复了此错误。
我想 运行 一些集成测试,其中包括使用 org.testcontainers Docker Compose 模块设置完整的环境。我是 Windows 和 Docker 测试的新手,与测试容器一样。
使用版本:
- Docker 桌面社区:2.5.0.0
- org.testcontainers:测试容器:1.15.0
- org.springframework.boot 2.3.4.
我的代码如下所示:
@ClassRule
public static DockerComposeContainer environment = new DockerComposeContainer(
new File("C:\dev\myproject\myapp\docker-compose\docker-compose.env.yml"),
new File("C:\dev\myproject\myapp\docker-compose\docker-compose.yml"))
.withExposedService("myservice_1", 9999)
.withLocalCompose(true);
我的撰写文件看起来像这样。
services:
myservice:
image: myapp/myservice:latest
hostname: myservice
volumes:
- ../volumeDir:/app/volumeDir
- ../config:/app/config
expose:
- 9999
ports:
- 9999:9999
command: -Dspring.liquibase.enabled=true
networks:
- internet
看起来像一些绑定错误,堆栈跟踪的最重要部分:
> java.lang.RuntimeException: java.lang.RuntimeException: org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.ValueInstantiationException:
> Cannot construct instance of `com.github.dockerjava.api.model.Binds`,
> problem: Error parsing Bind
> 'C:\dev\myproject\myapp\volumeDir:/app/volumeDir:rw'
> at [Source: (org.testcontainers.shaded.okio.RealBufferedSource); line: 1,
> column: 1369] (through reference chain:
> com.github.dockerjava.api.command.InspectContainerResponse["HostConfig"]->com.github.dockerjava.api.model.HostConfig["Binds"])
> at org.rnorth.ducttape.timeouts.Timeouts.callFuture(Timeouts.java:68)
> at org.rnorth.ducttape.timeouts.Timeouts.doWithTimeout(Timeouts.java:60)
> at org.testcontainers.containers.wait.strategy.WaitAllStrategy.waitUntilReady(WaitAllStrategy.java:53)
> ...
我试过把路径改成absolute,没有任何区别。您有什么想法可以使此绑定无法解析吗?
此错误是由于 Testcontainers 的当前问题以及 Windows 版本的最新 Docker。他们是 already aware of it and a fix seems close to being merged.
更新:版本 1.15.1 现已可用,修复了此错误。