🎈个人主页:靓仔很忙i
💻B 站主页:👉B站👈
🎉欢迎 👍点赞✍评论⭐收藏
🤗收录专栏:SpringBoot
🤝希望本文对您有所裨益,如有不足之处,欢迎在评论区提出指正,让我们共同学习、交流进步!
环境搭建
新建springboot
springboot实战—2.快速搭建web系统
docker插件安装
File–Settings–Plugins–docker–Install
配置docker
镜像制作
DockerFile
在src同级目录下,新建Dockerfile文件,内容如下:
FROM openjdk:8
MAINTAINER xlwang
ADD target/demo-0.0.1-SNAPSHOT.jar test.jar
ENTRYPOINT ["java","-jar","/test.jar"]
pom.xml编辑
(plugin标签位于下的下的)
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<dockerHost>http://47.107.71.52:2375</dockerHost>
<imageName>xlwang/${project.artifactId}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
</imageTags>
<forceTags>true</forceTags>
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
idea上传docker
maven编译并上传
clean package -Dmaven.test.skip=true