我正在尝试在集成测试之前在 docker 容器中docker-maven-plugin
运行redis
和实例。PostgreSQL 11
以下是我在pom.xml
文件中的设置:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven.version}</version>
<configuration>
<verbose>true</verbose>
<images>
<image>
<alias>docker-dbs</alias>
<external>
<type>compose</type>
<composeFile>docker-compose-test.yml</composeFile>
</external>
<run>
<wait>
<time>5000</time>
<log>Docker databases are ready to accept connections</log>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>start-docker-dbs</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-docker-dbs</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
我正在尝试运行docker-compose-test.yml
包含以下内容的指定文件中定义的服务:
version: "3.8"
alias: docker-dbs
services:
redis:
image: "redis:alpine"
command: redis-server
environment:
- REDIS_REPLICATION_MODE=master
ports:
- "5378:6379"
postgres:
image: "postgres:11"
restart: always
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: topfind-accounts-test-db
ports:
- "4431:5432"
我知道这个文件是正确的,因为我试图手动运行它,但是maven
当我需要它时我无法为我运行它。关于为什么这不起作用的任何建议?