Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Docker绑定解析异常与testcontainers_Java_Windows_Docker_Testcontainers_Docker Java - Fatal编程技术网

Java Docker绑定解析异常与testcontainers

Java Docker绑定解析异常与testcontainers,java,windows,docker,testcontainers,docker-java,Java,Windows,Docker,Testcontainers,Docker Java,我想运行一些集成测试,包括使用org.testcontainers Docker Compose模块建立一个完整的环境。我不熟悉Windows和Docker测试,testcontainers也是如此 使用版本: Docker桌面社区:2.5.0.0 org.testcontainers:testcontainers:1.15.0 org.springframework.boot2.3.4 我的代码如下所示: @ClassRule public static DockerComposeCont

我想运行一些集成测试,包括使用org.testcontainers Docker Compose模块建立一个完整的环境。我不熟悉Windows和Docker测试,testcontainers也是如此

使用版本:

  • Docker桌面社区:2.5.0.0
  • org.testcontainers:testcontainers:1.15.0
  • org.springframework.boot2.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
看起来像是绑定错误,stacktrace中最重要的部分:

>     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$1); 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)
>     ...

我试着把这条路改成绝对的,没有任何区别。您知道什么可以使此绑定不可解析吗?

此错误是由于Testcontainers和最新的Docker for Windows版本的当前问题造成的。它们是和一个


更新:现已提供修复此错误的版本。

您是否尝试过使用docker compose up-d测试compose文件?@Vitaly Chura它在没有testcontainers的情况下工作。感谢您的更新!