Official website: https://spring.io/guides/gs/spring-boot-docker/
Reference documents: https://my.oschina.net/AmosWang/blog/2088358
1. In the pom files of the project added:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}
</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
<properties>
<java.version>1.8</java.version>
<docker.image.prefix>pheony</docker.image.prefix>
</properties>
Add Dockerfile file in the project directory
FROM openjdk:8-jdk-alpine VOLUME /tmp ARG JAR_FILE COPY ${JAR_FILE} app.jar ENTRYPOINT ["java","-jar","/app.jar"]
2. Project Package
idea directly to the right column install or mvn install packages, generating files in the target directory
3. Local installation docker open shell run under the project directory: mvn clean package docker: build
错误:No plugin found for prefix 'docker' in the current project and in the plugin groups.
Modify the configuration file maven settings.xml
<pluginGroups> <pluginGroup>com.spotify</pluginGroup> </pluginGroups>
错误:Must specify baseImage if dockerDirectory
使用mvn clean package dockerfile:build
4. The local repository mirror upload, docker pull server