0

我正在尝试在集成测试之前在 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 当我需要它时我无法为我运行它。关于为什么这不起作用的任何建议?

4

1 回答 1

0

看起来仍然不支持 Composer 文件的 3.x 版本。

我遇到了类似的问题并看到错误消息: Execution start of goal io.fabric8:docker-maven-plugin:0.33.0:stop failed: Only version 2.x of the docker-compose format is supported for src/main/docker/docker-compose.yml

于 2020-08-21T12:31:07.490 回答