修改宿主机的docker配置,让其可以远程访问
vi /lib/systemd/system/docker.service
1
其中ExecStart=后添加配置 ‐H tcp://0.0.0.0:2375 ‐H unix:///var/run/docker.sock
刷新配置,重启服务
systemctl daemon‐reload
systemctl restart docker
docker start registry
1
2
3
修改项目pom文件
<build> <finalName>app</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <executable>true</executable> </configuration> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.2.0</version> <configuration> <imageName>192.168.211.132: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.211.132:2375</dockerHost> </configuration> </plugin> </plugins> </build>
打包之后 然后进行放置到私有仓库中
mvn docker:build -DpushImage