0

I am using the testcontainers withReuse function in Groovy to reuse the containers between builds. After the tests run, the containers don't get deleted anymore. However, when I run the tests again, instead of reusing the existing one it creates a duplicate container. I want it to reuse the container it created during the last run.

Here is my the code in my GROOVY script.

    println "starting k3s container..."

    k3sContainer = new K3sContainer(DockerImageName.parse(RANCHER_IMAGE))
            .withLogConsumer(new Slf4jLogConsumer(log))
            .withNetwork(network)
            .withNetworkAliases(K3S_HOSTNAME)
            .withReuse(true)
    k3sContainer.start()

    println "K3S Started"

I have also added the following to my .testcontainers.properties file

#Mon Jun 13 10:42:31 EDT 2022
docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
testcontainers.reuse.enable=true
Ajay
  • 21
  • 2

1 Answers1

0

testcontainers.reuse.enable is currently a preview feature. As such, it has some limitations. One of them is, that it won't work if Testcontainers networks are used.

What is the use case for the network in this case?

Kevin Wittek
  • 1,369
  • 9
  • 26