自己创建一个springboot项目(application.yml配置端口8090)
参考https://blog.csdn.net/weixin_41029286/article/details/117406869idea连接docker
引入docker-maven-plugin的包
<build>
<finalName>docker-maven-plugin</finalName>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<!-- 生成的镜像名-->
<imageName>${project.artifactId}:${project.version}</imageName>
<!-- 使用的镜像-->
<baseImage>openjdk:8-alpine3.9</baseImage>
<!-- 远程docker地址-->
<dockerHost>http://192.168.247.131:2375</dockerHost>
<!-- 启动容器后执行-->
<entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint>
<!-- 推送私有库-->
<!-- <pushImage>true</pushImage>-->
<!-- <registryUrl>192.168.247.130:5000/dockerRegistry</registryUrl>-->
<resources>
<resource>
<!-- 这里是复制 jar 包到 docker 容器指定目录配置 -->
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<!--把哪个文件上传到docker,相当于Dockerfile里的add app.jar /-->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.0.RELEASE</version>
</plugin>
</plugins>
</build>
执行打包命令
mvn clean package docker:build
idea的services中右键镜像创建容器
测试一下自己的接口