mvn clean package -D maven.test.skip=true -DpushImage
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>${docker.registry}/${project.name}-${branch.env}:${maven.build.timestamp}</imageName><!-- 公司项目名称,时间戳 -->
<imageTags>
<imageTag>${maven.build.timestamp}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>${basedir}</dockerDirectory><!-- Dockerfile文件地址 -->
<resources>
<resource>
<targetPath>/</targetPath>
<!-- ${project.build.directory},项目构建输出目录,默认为target/ -->
<directory>${project.build.directory}</directory>
<!-- ${project.build.directory},打包出来的jar名称,默认为${project.artifactId}-${project.version} -->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<dockerHost>${docker.remoteapi.dockerHost}</dockerHost>
</configuration>
<!--绑定docker命令到mvn命令的生命周期里去,执行mvn package会执行镜像构建,打标签,推送-->
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>tag-image</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
</goals>
<!-- tag打标签的规范:私仓的url:port/项目名变-分支变量:时间戳 -->
<configuration>
<image>${docker.registry}/${project.name}-${branch.env}:${maven.build.timestamp}</image>
<newName>${docker.registry}/${project.name}-${branch.env}:latest</newName>
<forceTags>true</forceTags>
</configuration>
</execution>
<execution>
<id>push-image</id>
<phase>deploy</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
查询镜像列表
http://192.168.45.154:5000/v2/_catalog
查看具体镜像版本 fristspringboot-devbranch 名称
http://192.168.45.154:5000/v2/fristspringboot-devbranch/tags/list
容器内物理删除镜像
docker exec <容器名> rm -rf /var/lib/registry/docker/registry/v2/repositories/<镜像名>
挂载的本地删除:rm -fr /home/registry/docker/registry/v2/repositories/*