如何在每次使用Maven执行测试之前重新启动Docker容器?

问题描述

我想在每次执行单个测试之前启动一个新的postgres docker容器,而不是在运行所有集成测试之前启动一个。 我目前拥有的配置就像大多数Google结果所建议的一样:

     <plugins>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.33.0</version>
                <configuration>
                    <imagePullPolicy>IfNotPresent</imagePullPolicy>
                    <images>
                        <image>
                            <alias>it-database</alias>
                            <name>postgres:11.3</name>
                            <run>
                                <namingStrategy>alias</namingStrategy>
                                <ports>
                                    <port>5555:5432</port>
                                </ports>
                                <wait>
                                    <log>(?s)database system is ready to accept connections.*database system is ready to accept connections
                                    </log>
                                    <time>20000</time>
                                </wait>
                            </run>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <id>docker:start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>docker:stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)