首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >docker-maven-plugin不创建dockerfile

docker-maven-plugin不创建dockerfile
EN

Stack Overflow用户
提问于 2019-08-08 01:26:43
回答 2查看 1.2K关注 0票数 2

我正在使用docker-maven-plugin为Java微服务创建dockerfile和docker镜像。当我运行命令mvn package -DskipTest=true时,它没有创建Dockerfile。

我正在使用docker-maven-plugin为Java微服务创建dockerfile和docker镜像。当我运行命令mvn package -DskipTest=true时。它可以成功运行,没有任何错误,但不会生成Dockerfile。看一下发送到屏幕上的消息,尽管插件是在“build”中配置的,但看起来并不像是运行的。

以下是pom.xml中构建任务的配置:

代码语言:javascript
复制
 <build>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-maven-plugin</artifactId>
                        </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.1.1</version>
                <configuration>
                    <imageName>explorecali-${ec-profile}</imageName>
                    <baseImage>java</baseImage>
                    <entryPoint>["java", "-Dspring.profiles.active=${ec-profile}", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <forceTags>true</forceTags>
                    <buildArgs>
                        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

        </plugins>
        </build>

没有错误消息,但没有Dockefile。下面是当我运行它时向屏幕发出的消息:

代码语言:javascript
复制
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.ec:explorecali >---------------------
[INFO] Building explorecali 2.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ explorecali ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ explorecali ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ explorecali ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\fikhas\dev\spring\Ex_Files_Ext_Docker_Spring_Boot\Exercise Files\Ch05\05_05\explorecali\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ explorecali ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ explorecali ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ explorecali ---
[INFO] Building jar: C:\Users\fikhas\dev\spring\Ex_Files_Ext_Docker_Spring_Boot\Exercise Files\Ch05\05_05\explorecali\target\explorecali-2.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ explorecali ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.576 s
[INFO] Finished at: 2019-08-07T13:25:58-04:00
[INFO] ------------------------------------------------------------------------
EN

回答 2

Stack Overflow用户

发布于 2019-08-08 02:42:07

你可能需要运行"maven package docker:build“而不仅仅是"maven package”。为了将docker构建绑定到maven阶段,您还可以尝试如下所示:

代码语言:javascript
复制
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>

来自https://github.com/spotify/docker-maven-plugin#bind-docker-commands-to-maven-phases

票数 1
EN

Stack Overflow用户

发布于 2019-11-15 18:06:38

您可能还需要使用dockerfile-maven-plugin而不是docker-maven-plugin(当前处于非活动状态)

代码语言:javascript
复制
  <artifactId>dockerfile-maven-plugin</artifactId>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57399529

复制
相关文章

相似问题

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