第一步先让idea连接到docker不知道怎么连接的点击我 {#tid-hfzxJc}
开始导入插件
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<executions>
<execution>
<id>build-image</id>
<!--用户只需执行mvn package ,就会自动执行mvn docker:build-->
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${project.artifactId}</repository>
<tag>${project.version}</tag>
</configuration>
</plugin>
新建Dockerfile注意位置别放错如图:
FROM openjdk:8-jre
MAINTAINER xxxxx Docker springboot "xxxxx@xxx.com"
ENV TZ Asia/Shanghai
COPY target/xxxxxxx.jar app.jar
ENTRYPOINT ["java","-Xms256m","-Xmx512m","-jar","app.jar"]
Maven添加环境变量
依次执行clean,compile,package {#tid-EZZsBf}
这样镜像就构建成功了
完事