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

docker-maven-plugin未创建dockerfile

罗昊空
2023-03-14

我正在使用docker-maven-plugin为Java微服务创建一个dockerfile和docker映像。当我运行命令mvn package-dskiptest=true时,它不会创建DockerFile。

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

 <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。下面是我运行时向屏幕发出的消息:

[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] ------------------------------------------------------------------------

共有1个答案

仲孙毅
2023-03-14

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

<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

 类似资料:
  • docker maven plugin 是个简单的可以管理Docker容器maven插件,这个插件将会根据你的配置,在构建时启动容器,构建结束时停止容器并删除,如果本地找不到镜像,Docker会自动去中央仓库下载。 简单示例: <plugin>    <groupId>com.ofbizian</groupId>    <artifactId>docker-maven-plugin</artifa

  • Docker Compose Maven Plugin Quickstart Available on Maven Central. <dependency> <groupId>com.dkanejs.maven.plugins</groupId> <artifactId>docker-compose-maven-plugin</artifactId> <version>$VER

  • 我正在尝试为我的spring-boot应用程序构建一个docker映像。这是我的DockerFile: 这是我的pom.xml文件,其中有我的io.fabric8插件: 当我试图使用构建docker映像时,我得到一个错误: 无法执行目标IO.fabric8:docker-maven-plugin:0.15.3:在项目详细信息上生成(default-cli)app:执行目标IO.fabric8:do

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

  • 当我使用docker-maven-plugin构建docker映像时,它失败了 错误:无法执行目标com.spotify:docker-maven-plugin:1.0.0:build(default-cli)on project spring-boot-basic:捕获异常:basedir/root/workspace/spring-boot-basic/spring-boot-basic/sp

  • 问题内容: 我有一个Maven项目,我想从中创建两个可执行的jar文件。一个将与用户交互使用,第二个将作为计划作业运行,读取前者生成的日志文件。最后,除了MANIFEST.MF文件中的Main- Class属性外,我希望两个jar文件都相同。 我正在使用maven-antrun- plugin创建一个可执行jar,在我尝试通过引入Maven配置文件尝试创建第二个jar文件之前,这似乎工作得很好。我