【问题标题】:Spotify docker maven build multiple imagesSpotify docker maven 构建多个图像
【发布时间】:2016-12-22 16:41:32
【问题描述】:

我正在使用 spotify 的 Docker maven 插件,并希望构建两个不同的映像,一个是数据库 (MariaDB),另一个是 Java EE 映像 (Glassfish)。

我已经设法让 Maven 在单独运行时构建图像,但是当我尝试在同一个 POM 文件中运行它们时,它只会创建第一个图像。

我尝试在单个插件中放置两个配置部分并得到以下错误:

[错误] 不可解析的 POM C:\Users\607819425\Documents\InteliJProjects\feature_docker\pom.xml:重复的标签:“配置”(位置:START_TAG 看到 ...\r\n ...@300 :32) @line 300,第 32 列 -> [帮助 2]

在一个插件中包含 2 个配置标签的 Pom 文件

            <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.11</version>
            <configuration>
                <imageName>glassfish</imageName>
                <dockerDirectory>glassfish</dockerDirectory>
                <baseImage>java</baseImage>
                <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                <!-- copy the service's jar file from target into the root directory of the image -->
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
            <configuration>
                <imageName>mariadb</imageName>
                <dockerDirectory>mariadb</dockerDirectory>
                <baseImage>java</baseImage>
                <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                <!-- copy the service's jar file from target into the root directory of the image -->
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>

而且还有两个单独的插件,它只构建第一个图像。

两个插件 POM:

<plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.11</version>
            <configuration>
                <imageName>glassfish</imageName>
                <dockerDirectory>glassfish</dockerDirectory>
                <baseImage>java</baseImage>
                <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                <!-- copy the service's jar file from target into the root directory of the image -->
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.11</version>
            <configuration>
                <imageName>mariadb</imageName>
                <dockerDirectory>mariadb</dockerDirectory>
                <baseImage>java</baseImage>
                <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                <!-- copy the service's jar file from target into the root directory of the image -->
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>

你能提供的任何信息都会很棒!

【问题讨论】:

    标签: java maven docker spotify


    【解决方案1】:

    由于支持多张图片,我最终切换到了 Fabric8.io 的插件版本。

    Fabric 8 Docker Maven Plugin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-05
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多