Creating a Docker image using Maven

If you have used Maven to resolve dependencies but the Maven provides support to create a build by adding some plugins to the Maven configuration file pom.xml. So, if you want to create a Docker image by using the Maven commands, you have to add a new plugin in the Maven pom.xml file. Consider the following:

<properties> ... <docker.image.prefix>doj</docker.image.prefix> </properties> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.3.4</version> <configuration> <repository>${docker.image.prefix}/${project.artifactId}</repository> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.