首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由Google Jib和Maven构建的Docker镜像的多个标签?

由Google Jib和Maven构建的Docker镜像的多个标签?
EN

Stack Overflow用户
提问于 2021-04-09 16:10:09
回答 1查看 2K关注 0票数 1

使用jib-maven-plugin,我想构建一个带有多个标签的图像。虽然mvn jib:build基本上工作得很好,但它“只”用latest标记图像。

我的Maven pom.xml定义了以下内容:

代码语言:javascript
复制
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>2.8.0</version>
    <configuration>
        <to>
            <image>my-private-registry.org/my-image</image>
        </to>
    </configuration>
</plugin>

The docs展示了可以在XML中使用jib.to.tags来定义标记列表。但是,我想在Jenkins管道中运行构建步骤,即我不能在pom.xml中对标记进行硬编码。

在运行mvn命令时,是否可以通过设置一些-D参数来传递标记列表?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-09 22:46:09

使用-Djib.to.tags=a,b,c

代码语言:javascript
复制
$ mvn package jib:build -Djib.to.tags=a,b,c
...
[INFO] --- jib-maven-plugin:2.8.0:dockerBuild (default-cli) @ hello-spring-boot ---
[INFO] Tagging image with generated image reference hello-spring-boot:0.1.0. If you'd like to specify a different tag, you can set the <to><image> parameter in your pom.xml, or use the -Dimage=<MY IMAGE> commandline flag.
[INFO] 
[INFO] Containerizing application to Docker daemon as hello-spring-boot:0.1.0, hello-spring-boot:a, hello-spring-boot:b, hello-spring-boot:c...
[WARNING] Base image 'gcr.io/distroless/java:8' does not use a specific image digest - build may not be reproducible
[INFO] Using base image with digest: sha256:34c3598d83f0dba27820323044ebe79e63ad4f137b405676da75a3905a408adf
[INFO] 
[INFO] Container entrypoint set to [java, -Djava.security.egd=file:/dev/./urandom, -cp, /app/resources:/app/classes:/app/libs/*, hello.Application]
[INFO] 
[INFO] Built image to Docker daemon as hello-spring-boot:0.1.0, hello-spring-boot:a, hello-spring-boot:b, hello-spring-boot:c
[INFO] 
[INFO] A new version of Jib (3.0.0) is available (currently using 2.8.0). Update your build configuration to use the latest features and fixes!
[INFO] https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/CHANGELOG.md
[INFO] Please see https://github.com/GoogleContainerTools/jib/blob/master/docs/privacy.md for info on disabling this update check.
[INFO] 
[INFO] Executing tasks:
[INFO] [==============================] 100.0% complete
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67017380

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档