配置到pom.xml文件上
关于pom.xml的配置
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<!--使用最简单的部署方式进行测试-->
<configuration>
<!--注意imageName一定要是符合正则[a-z0-9-_.]的,否则构建不会成功 -->
<!-- 详见:https://github.com/spotify/docker-maven-plugin Invalid repository name ... only [a-z0-9-_.] are allowed-->
<imageName>test01</imageName>
<baseImage>java</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
使用dockerfile部署的方式
关于pom.xml的配置
<build>
<finalName>${project.artifactId}‐${project.version}</finalName>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<!‐‐docker镜像的配置信息‐‐>
<configuration>
<imageName>${project.artifactId}-${project.version}</imageName>
<dockerDirectory>${project.basedir}/src/main/resources</dockerDirectory>
<imageTags>
<imageTag>${project.version}</imageTag>
</imageTags>
<imageName>${project.artifactId}:${project.version}</imageName>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.artifactId}‐${project.version}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
dockerfile的配置
dockerfile的文件位置 参照pom.xml的配置位置 这里是放到resources 目录下
FROM java:8
ENV ARTIFACTID test02
ENV ARTIFACTVERSION 1.0-SNAPSHOT
ENV HOME_PATH /home
WORKDIR $HOME_PATH
ADD $ARTIFACTID‐$ARTIFACTVERSION.jar $HOME_PATH/$ARTIFACTID.jar
ENTRYPOINT ["java", "‐jar", "test02.jar"]
configuration
imagesName 镜像名
dockerDirectory dockerfile文件路径
imageTags 后缀
resources 镜像的基本信息