Clarification on Maven profiles and Phases

In my maven project, I have multiple maven profiles. In each profile, I have docker-maven-plugin and maven-failsafe-plugin. This is how I have bound goals and phases.

docker-maven-plugin

  • How to restart multiple containers in a docker swarm
  • ImportError only when I use docker
  • how jenkins in a docker access git-repo of gitlab in another docker
  • Bash restore database to a docker container for a WordPress + Piwik Solution
  • Does putting ARG at top of Dockerfile prevent layer re-use?
  • Deploy image to AWS Elastic Beanstalk from private Docker repo
  • <phase>pre-integration-test</phase>
    <goals>
       <goal>start</goal>
    </goals>
    
    <phase>post-integration-test</phase>
    <goals>
       <goal>stop</goal>
       <goal>remove</goal>
    </goals>
    

    maven-failsafe-plugin

    <phase>integration-test</phase>
    <goals>
       <goal>integration-test</goal>
    </goals>
    
    <phase>verify</phase>
    <goals>
       <goal>verify</goal>
    </goals>
    

    I have profiles for each database type (i.e. MySQL, Postgres etc.). What I’m trying to do is that run my integration tests on docker with each database type.

    My question is that, can I run mvn with multiple profiles (i.e. mvn clean install -P local-postgres,local-mysql), so that each profile is executed one after the other? My requirement is not to have 2 docker containers up at once.

    What I observed is that pre-integration-test phases of all profiles run first, and fails with The name "/apim-postgres" is already in use by container xxxxx. Is that how maven phases are supposed to work when multiple profiles are given?

    Is there a way I can get my requirement fulfilled?

  • Docker for Mac. docker run -d -p 80:80 --name webserver nginx shows another container with this name. but docker ps shows empty list
  • Docker eating up disk space /var/lib/docker/devicemapper/devicemapper
  • Deploy group in marathon
  • docker build with a template Dockerfile
  • Play change RUNNING_PID file path
  • ansible-docker invalid container.yml
  • One Solution collect form web for “Clarification on Maven profiles and Phases”

    I’m not sure if this will work, but if you define each profile independently it should work. You define each plugin twice, one for each profile. The order of execution depends on various factors. I don’t know where you have defined the profiles, but if they are defined in the same pom then the order should be the one defined in that pom. See https://www.waltercedric.com/index.php?option=com_content&view=article&id=1795&catid=129&Itemid=332 for more help.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.