当前位置: 首页 > 知识库问答 >
问题:

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

萧伟兆
2023-03-14

我想用fabric8-maven-plugin构建一个Docker映像,并将其推送到一个自定义注册表(gcr.io/ /demo123 )。然而,maven插件总是使用项目的组/工件id来派生图像标记。我以为可以通过 标记手动配置标记,但这不起作用...有什么想法吗?

执行maven目标fabric8:build的结果是

[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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>3.5.33</version>
            <configuration>
                <verbose>true</verbose>
                <images>
                    <image>
                        <name>gcr.io/myid/demo123</name>
                    </image>
                </images>
            </configuration>
            <executions>
                <execution>
                    <id>fmp</id>
                    <goals>
                        <goal>resource</goal>
                        <goal>build</goal>
                        <goal>push</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

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

共有1个答案

颛孙俊
2023-03-14

遇到了同样的问题。添加标记build修复了它。无法解释原因,也许别人知道。

<images>
  <image>
    <name>gcr.io/myid/demo123</name>
    <build></build>
  </image>
</images>
 类似资料:
  • Deprecation Note: This project has been moved to https://github.com/eclipse/jkube . All new features would be implemented there and support for FMP would be eventually dropped. fabric8-maven-plugin In

  • 问题内容: 我想使用properties-maven-plugin。我阅读了用法http://mojohaus.org/properties-maven- plugin/usage.html ,但是它对我不起作用。 我创建了一个非常简单的项目对其进行测试。这是我的pom.xml: 如果我运行mvn compile或mvn install,则结果为: “ my.properties”文件包含以下内容

  • 在为Selenium创建maven项目时,我通常将maven编译器插件和maven surefire插件放在插件标签下,如下所示: 但我在maven central repo看到了对他们的依赖 那么我们可以将这些作为依赖项而不是插件吗?

  • 我假设语法与ADD local-artifact-version.jar app.jar相似,但这不起作用。 问题:当我运行mvn clean package Docker:Build Docker:start-ddocker.follow=true时,我得到一个错误 在使用fabric8 docker maven插件时,DockerFile的“add”语义的正确用法是什么?

  • 我从原型io开始。fabric8:camel cxf代码是第一个原型,但我无法使用以下maven命令进行部署,因为没有定义fabric8。mvn-P!Spring Boot清理编译-X fabric8:deploy-DskipTests=true-Dfabric8。upload=true-Dfabric8。约洛基亚尔=http://10.191.231.12:8181/jolokia 然后我修改了

  • 我想通过docker compose构建图像,并为其设置特定标记。文件说: Comment将构建并用生成的名称标记它,然后使用该映像。 但是我找不到指定标签的方法,对于构建的图像,我总是看到“最新”标签。