Pom.xml
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy todir="src/main/docker" file="target/${project.build.finalName}.${project.packaging}"></copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
在Main底下,与java目录同级 建一个docker文件夹
放入Dockerfile
FROM java:8
VOLUME /home/dockerLog
ADD XXX(包名) app.jar
RUN bash -c "touch /app.jar"
EXPOSE 80
ENTRYPOINT ["java","-jar","app.jar"]