如何使用fabric8-maven-plugin标记图像?

时间:2018-02-10 21:06:51

标签: maven docker spring-boot fabric8 google-kubernetes-engine

我想使用fabric8-maven-plugin构建一个Docker镜像,并将其推送到自定义注册表(gcr.io/<myid>/demo123)。但是,maven插件始终使用项目的组/工件ID来派生图像标记。我以为我可以通过<name>的{​​{1}}标记手动配置代码,但这不起作用......任何想法?

执行maven目标<image>会导致

fabric8:build

这是我的pom.xml

[INFO] F8: Successfully tagged example/demo:snapshot-180210-220255-0223
[INFO] F8: [example/demo:snapshot-180210-220255-0223] "spring-boot": Built image sha256:003d6
[INFO] F8: [example/demo:snapshot-180210-220255-0223] "spring-boot": Tag with latest

提前致谢!

解决方案:https://github.com/fabric8io/fabric8-maven-plugin/issues/1180

2 个答案:

答案 0 :(得分:0)

我在pom.xml中以这种方式配置并且它可以工作

```

<id>buildprofile</id>
<build>
    <plugins>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>3.5.35</version>

            <configuration>
            <images>
        <image>
          <name>{image.user}/{image.name}:{image.tag}</name>
        </image>
      </images>
    </configuration>

    <executions>
      <execution>
        <goals>
          <goal>resource</goal>
          <goal>build</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

```

我点击了mvn clean install -Pbuildprofile

答案 1 :(得分:0)

遇到同样的问题。添加标签build修复了该问题。无法解释为什么,也许别人知道。

<images>
  <image>
    <name>gcr.io/myid/demo123</name>
    <build></build>
  </image>
</images>