mvn-docker插件打包上传镜像到registry

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/*

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值