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