Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

manage docker with maven

In this example I'm going to demonstrate how easily amd quick postgres database can be started in docker by using fabric8 docker-maven-plugin

Table of Content

install

assuming you have in your pom.xml file:

 <properties>
<postgres.docker.name>healthcheck/postgres:alpine</postgres.docker.name>
<postgres.docker.log.prefix>postgres</postgres.docker.log.prefix>
<postgres.docker.ports.1>5432:5432</postgres.docker.ports.1>
<!--<postgres.docker.ports.1>${itest.postgres.port}:5432</postgres.docker.ports.1>-->
<postgres.docker.env.POSTGRES_DB>postgres</postgres.docker.env.POSTGRES_DB>
<postgres.docker.envRun.POSTGRES_USER>postgres</postgres.docker.envRun.POSTGRES_USER>
<postgres.docker.envRun.POSTGRES_PASSWORD>postgres</postgres.docker.envRun.POSTGRES_PASSWORD>
<postgres.docker.wait.time>10000</postgres.docker.wait.time>
<postgres.docker.wait.log>PostgreSQL init process complete</postgres.docker.wait.log>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.28.0</version>
<configuration>
<allContainers>true</allContainers>
<removeVolumes>true</removeVolumes>
<watchInterval>500</watchInterval>
<logDate>default</logDate>
<verbose>true</verbose>
<autoPull>always</autoPull>
<images>
<image>
<external>
<type>properties</type>
<prefix>postgres.docker</prefix>
</external>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>

start

start postgres container with docker run -d -p 5432:5432 ... healthcheck/postgres:apline command

mvn docker:start

stop

stop and remove container, like with docker rm -f -v postgres-1 command

mvn docker:start

help

mvn docker:help

cleanup if you missed to remove your other images

foriin$(docker images -q -f dangling=true);do docker rmi -f $i;done

read more

About

Manage Docker daemon with Maven

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors