docker-compose in fabric8's docker-maven-plugin not working

1.6k Views Asked by At

I'm trying to make docker-maven-plugin run redis and PostgreSQL 11 instances inside docker containers prior to integration tests. The following is my setup in the pom.xml file:

    <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>

I'm trying to run the services defined in the specified docker-compose-test.yml file which contains the following:

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"

I know for a fact that this file is correct as I've tried to run it manually, however I can't get maven to run it for me when I need it. Any suggestions as to why this would not work?

1

There are 1 best solutions below

1
C. Dolch On

It looks like that version 3.x of composer file is still not supported.

I've got a similar problem and see the error message: 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