[Error] reuseContainer does not work for embedded-kafka
Hello,
It seems like embedded-kafka keeps spawning new containers, even if reuseContainer flag is set to true. Please take a look at the code sample below:
https://github.com/arturk9/kafka-reuse-demo
Reproduction steps:
- run ./gradlew build multiple times in short interval
- reuse has no effect - new containers are spawned each time
Would it be possible to add support for embedded-kafka containers reuse?
Thank you in advance :)
Hi @arturk9,
Could you try version 3.0.0-RC5 and give feedback if the problem is gone ?
hello @Fameing
Once upgraded to 3.0.0-RC5, both containers mongo and kafka are not reused. I did some debugging, seems like the configuration is correct and "shouldBeReused" flag is set to true properly for both containers, but each execution still spawns new containers. After upgrading, not only new kafka container is created, but it seems like mongodb is no longer reusable.


The following condition is also evaluated as true:

Is there anything I am missing in the config?
Hi @arturk9 and @Fameing
Faced the same problem with kafka. In my case I have configuration through the bootstrap.yaml file.
Found out that reusing container is working as expected in case if we get rid of network for kafka. I just manually sets null to kafkaNetwork() bean through the debugger.
But still I didn't found how to remove network property when I'm using bootstrap.yml configuration not static

Thank you, I also found a problem that using Network for a container generates a different hash. This problem is related to testcontainer-java.
@Fameing Is it possible somehow to avoid network generation for Kafka through bootstrap config file? Or this is not possible for now?
Thanks in advance!
@arturk9 @Fameing My suggestion as a temporary workaround is to override bean kafkaNetwork (set this bean to null) as described here https://stackoverflow.com/questions/68898220/spring-boot-boostrap-bean-override