安装docker插件
setting -> plugins
配置docker远程连接
参考:docker配置远程连接端口
https://blog.csdn.net/jinying_51eqhappy/article/details/132103423?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22132103423%22%2C%22source%22%3A%22jinying_51eqhappy%22%7D
创建Dockerfile
vim Dockerfile
FROM openjdk:8-jdk-alpine
# 时区问题
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# 字体
COPY fonts/simsun.ttc /usr/share/fonts/simsun.ttc
ENV app=/app
WORKDIR $app
RUN mkdir -p $app/logs
COPY target/demo2-0.0.1-SNAPSHOT.jar $app/app.jar
EXPOSE 9003
# ENTRYPOINT ["java","-jar","demo2.jar"]
#ENTRYPOINT exec java -Dspring.profiles.active=dev $JAVA_OPTS -jar renren-admin.jar
ENTRYPOINT ["java", "-server", "-Xms512M", "-Xmx512M", "-Djava.security.egd=file:/dev/./urandom", "-Dfile.encoding=UTF-8", "-XX:+HeapDumpOnOutOfMemoryError", "-Dspring.profiles.active=prod", "-jar", "/app/app.jar" ]
选择一个基础镜像小的
配置Run/Debug Configuration 的 docker
配置pom
<properties>
<docker.image.prefix>docker-demo2</docker.image.prefix>
<docker.plugin.version>0.4.12</docker.plugin.version>
<registry.url>node2:5000</registry.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.10</version>
<executions>
<execution>
<id>default</id>
<goals>
<!--如果package时不想用docker打包,就注释掉这个goal-->
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${registry.url}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<!--提供参数向Dockerfile传递-->
<!-- <finalName>${project.artifactId}-${project.version}</finalName>-->
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>