[英]How to force Testcontainers to use specific docker image?
I usually run my spring-boot-test
junit sql tests on a Testcontainers
setup like this:我通常在这样的Testcontainers
设置上运行我的spring-boot-test
junit sql 测试:
spring.datasource.url=jdbc:tc:mariadb:10.5.8:///test
spring.datasource.username=test
spring.datasource.password=test
Question: when I omit the docker image value, like spring.datasource.url=jdbc:tc:mariadb:///test
, how can I force to always use a fixed docker image version? Question: when I omit the docker image value, like spring.datasource.url=jdbc:tc:mariadb:///test
, how can I force to always use a fixed docker image version?
My goal is to provide a test-commons.jar
that every project should include.我的目标是提供每个项目都应包含的test-commons.jar
。 So projects should all use the same default mariadb image defined in the commons jar, and not set the image explicit themselves.所以项目都应该使用公共 jar 中定义的相同的默认 mariadb 图像,并且不要将图像设置为显式。
Is that possible?那可能吗?
You can copy MariaDBContainerProvider , use "mymariadb" or "custommariadb" as the database type and set the desired version in newInstance()
.您可以复制MariaDBContainerProvider ,使用“mymariadb”或“custommariadb”作为数据库类型,并在newInstance()
中设置所需的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.