1.安装好Docker以后开启2375端口即可
vi /usr/lib/systemd/system/docker.service
2.Maven打包插件配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<!--用于指定镜像名称 -->
<imageName>192.168.3.166:5000/demo:${project.version}</imageName>
<!--用于指定基础镜像,相当于Dockerfile中的FROM指令 -->
<baseImage>java</baseImage>
<!--相当于Dockerfile的ENTRYPOINT指令 -->
<entryPoint>["java","-Duser.timezone=GMT+08","-jar", "/${project.build.finalName}.jar"]</entryPoint>
<!--是否跳过docker build -->
<skipDockerBuild>false</skipDockerBuild>
<resources>
<resource>
<targetPath>/</targetPath>
<!--用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
<directory>${project.build.directory}</directory>
<!--用于指定需要复制的文件。${project.build.finalName}.jar指的是打包后的jar包文件。 -->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<dockerHost>http://192.168.3.166:2375</dockerHost>
</configuration>
</plugin>
<!--mvn clean package docker:build -DpushImage skipTests -->
</plugins>
</build>
执行mvn clean package docker:build -DpushImage 即可上传到指定服务器 Rancher手动点击升级即可