There is good documentation on Spring-Boot integration with Docker: https://spring.io/guides/gs/spring-boot-docker/
Essentially, you define your dockerfile in src/main/docker/Dockerfile and configure docker-maven-plugin as follows:
<build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.11</version> <configuration> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <dockerDirectory>src/main/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins>
Dockerfile:
FROM frolvlad/alpine-oraclejre8:slim VOLUME /tmp ADD gs-spring-boot-docker-0.1.0.jar app.jar RUN sh -c 'touch /app.jar' ENV JAVA_OPTS="" ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
Note that in this FROM frolvlad/alpine-oraclejre8:slim example FROM frolvlad/alpine-oraclejre8:slim is a small-fingerprint image based on Alpine Linux.
You should also be able to use a standard Java 8 image (which is based on Debian and may have a larger area). An extensive list of available Java base images can be found here: https://github.com/docker-library/docs/tree/master/openjdk .
source share