我的目标是在使用 docker-maven-plugin 构建我的 Spring Boot 应用程序时启动一个 MSSQL Docker 容器,因此在未来运行“mvn clean install”时,我希望我的构建跳过尝试启动已经运行的 docker 容器,因为它报告我的数据库容器已经启动并且我的构建中断的错误。pom.xml 中是否有任何配置可以完成,以便只有在尚未启动数据库容器的情况下才能启动它?如果它已经在运行,也许某种类型的检查可以跳过启动数据库容器?我在 pom.xml 中的当前配置:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-it-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<images>
<image>
<name>mcr.microsoft.com/mssql/server</name>
<alias>sa</alias>
<run>
<env>
<ACCEPT_EULA>Y</ACCEPT_EULA>
<SA_PASSWORD>password</SA_PASSWORD>
</env>
<ports>
<port>1433:1433</port>
</ports>
<wait>
<log>SQL Server is now ready for client connections</log>
<time>20000</time>
</wait>
</run>
</image>
</images>
</configuration>
</execution>
</plugin>