【问题标题】:docker-compose in fabric8's docker-maven-plugin not workingFabric8 的 docker-maven-plugin 中的 docker-compose 不起作用
【发布时间】:2020-08-16 20:00:13
【问题描述】:

我正在尝试让 docker-maven-plugin 在集成测试之前在 docker 容器中运行 redisPostgreSQL 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 为我运行它。关于为什么这不起作用的任何建议?

【问题讨论】:

  • 能否请您也发布错误日志。
  • 没有错误。似乎maven-surefire-plugin 阻止它运行,如果我这样做-DskipTests 它会运行,但我的图像不会被构建和运行。

标签: spring-boot docker maven docker-maven-plugin


【解决方案1】:

3.x 版本的 composer 文件似乎仍然不受支持。

我遇到了类似的问题并看到错误消息: 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

【讨论】:

  • 我只有在使用-DskipTests 选项和mvn clean install 命令后才拥有这个。它基本上忽略了maven-surefire-plugin,此时该插件实际运行了!无论如何,降低版本没有帮助,我的图像没有运行:(
猜你喜欢
  • 1970-01-01
  • 2019-08-28
  • 1970-01-01
  • 2020-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-22
相关资源
最近更新 更多