1.使用DockerMaven,可以实现我们项目一键式部署,简便操作流程。
Maven插件自动部署步骤:
a.首先我们要设置docker的宿主机开启权限.
修改宿主机的docker配置,让其可以远程访问 vi /lib/systemd/system/docker.service
其中ExecStart=后添加配置 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
b.刷新配置,重启服务
systemctl daemon-reload
systemctl restart docker
docker start registry
c.在工程pom.xml 增加配置
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- docker的maven插件,官网:https://github.com/spotify/docker-maven-plugin
-->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>192.168.184.141:5000/${project.artifactId}:${project.version}
</imageName>
<baseImage>jdk1.8</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]
</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<dockerHost>http://192.168.184.141:2375</dockerHost>
</configuration>
</plugin>
</plugins>
</build>