fabric8 docker-maven-plugin:在构建中包含其他标签 [英] fabric8 docker-maven-plugin: include additional tags on build
问题描述
我在pom.xml中配置了fabric8 docker-maven-plugin,如下所示:
I have the fabric8 docker-maven-plugin configured in my pom.xml as follows:
<build>
...
<plugins>
...
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<images>
<image>
<name>${docker.image.prefix}/${project.artifactId}:%l</name>
<build>
<dockerFile>Dockerfile</dockerFile>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>
...
</plugins>
...
</build>
我正在使用%l
占位符,如果该版本包含 -SNAPSHOT
,则该占位符会使用 latest
标签标记图像,否则它将使用pom版本.从CI进行构建时,我想在图像中添加一些其他标签(可能包括一个以上的标签)(例如,内部版本号/分支名称),但我想保留%l
占位符行为.我认为应该可以从命令行使用maven属性,但是我无法从插件文档中找到它(https://dmp.fabric8.io/)
I'm using the %l
placeholder which tags the image with the latest
label if the version contains -SNAPSHOT
, otherwise it uses the pom version.
When building from CI, I'd like to include some additional tags (possibly more then one) to my image (e.g. build number / branch name) but I'd like to keep %l
placeholder behavior.
I think that it should be possible using maven properties from command line, but I couldn't figure it out from the plugin docs (https://dmp.fabric8.io/)
在执行docker:build目标时如何添加其他标签?
How can I include additional tags when executing the docker:build goal?
推荐答案
您可以使用< tags>
标签:
https://dmp.fabric8.io/#build-configuration >
<properties>
...
<!-- set default -->
<docker.image-tag>${project.version}</docker.image-tag>
...
</properties>
<image>
...
<name>repo/something/%a:%l</name>
<build>
...
<tags>
<tag>${docker.image-tag}</tag>
</tags>
...
</build>
...
</image>
这将同时使用%l
行为和自定义设置 $ {docker.image-tag}
标记您的图像.
this will tag your image with both the %l
behavior and the custom set ${docker.image-tag}
.
mvn docker:build -Ddocker.image-tag=mytag
这篇关于fabric8 docker-maven-plugin:在构建中包含其他标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!