pom.xml
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.34.1</version>
<configuration>
<images>
<image>
<name>阿里云镜像仓库namespace/%a:%v</name>
<registry>registry.cn-hangzhou.aliyuncs.com</registry>
<build>
<dockerFileDir>${basedir}/src/main/docker</dockerFileDir>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<tags>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</plugin>
maven settings.xml
<servers>
<server>
<id>registry.cn-hangzhou.aliyuncs.com</id>
<username>阿里云镜像仓库用户名</username>
<password>阿里云镜像仓库密码</password>
</server>
</servers>
dockerfile
FROM openjdk:11
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV TZ Asia/Shanghai
ADD maven/ /opt/
EXPOSE 80
ENTRYPOINT ["java", "-Dfile.encoding=UTF-8", "-Djava.security.egd=file:///dev/urandom","-jar","/opt/application.jar"]