简体   繁体   English

如何强制测试容器使用特定的 docker 图像?

[英]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.

相关问题 如何将本地 Docker 映像与 testcontainers 一起使用? - How to use local Docker image with testcontainers? 测试容器不使用本地 docker 映像 - Testcontainers doesn't use local docker image 使用 Jib 获取特定版本的图像(Maven、Docker、testcontainers) - Getting a specific version of an image with Jib (Maven, Docker, testcontainers) 如何从 Liquibase 更改日志中为 Testcontainers 构建 Docker 映像? - How to build Docker image for Testcontainers from Liquibase changelogs? 在Testcontainers中使用自定义DB docker-image - Using custom DB docker-image with Testcontainers 如何在现有应用程序中使用测试容器? - How to use testcontainers in existing application? 在 testcontainers 中使用 PostgreSQLContainer 和图像 on-the-fly - Use PostgreSQLContainer with image on-the-fly in testcontainers 使用测试容器运行带有自定义端口的 ES docker 图像 - Run ES docker image with custom port using testcontainers 测试容器超时等待容器端口打开,使用 Elasticsearch docker 镜像 - Testcontainers timed out waiting for container port to open, with Elasticsearch docker image 使用Artifactory代理到Docker Hub,在防火墙内部使用testcontainer进行测试 - Use Artifactory proxy to Docker Hub with testcontainers inside a firewall for testing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM