1

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?

curiousdev
  • 626
  • 8
  • 24
  • Could you please post the error log as well. – shred22 Aug 20 '20 at 14:14
  • There are no errors. It seems that `maven-surefire-plugin` is preventing it from running and if I do `-DskipTests` it will run, but my images won't be built and ran. – curiousdev Aug 21 '20 at 12:57

1 Answers1

1

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

C. Dolch
  • 11
  • 1
  • I've had this only after I used the option `-DskipTests` with `mvn clean install` command. It essentially ignored `maven-surefire-plugin` at which point this plugin actually ran! Anyway, reducing the version didn't help and my images did not run :( – curiousdev Aug 21 '20 at 12:56