I would like to run some integrational tests which would include setting up a complete environment with org.testcontainers Docker Compose Module. I am new to Windows and Docker testing, same with the testcontainers.
Using versions:
My code looks like the following:
@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);
My compose files looks something likes this.
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
It looks like some Binding error, the most significant part of the 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)
> ...
I have tried to change the path to absolute without any difference. Do you have any ideas what can make this bind unparseable?
This error is due to a current issue with Testcontainers and the recent Docker for Windows version. They are already aware of it and a fix seems close to being merged.
UPDATE: Version 1.15.1 is now available that fixes this bug.