[英]Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build on project 'foo': Could not build image:
We working in small team of 4 people.我们在 4 人的小团队中工作。 We using docker to deploy our services.
我们使用 docker 来部署我们的服务。 One of the services is a java Spring Boot project which is deployed after building docker image with maven.
其中一项服务是 java Spring 启动项目,该项目在使用 Z402C5D9AF6B430714D57 构建 docker 映像后部署。 To make docker image of Spring Boot service we use
mvn clean package dockerfile:build
.要制作 Spring 引导服务的 docker 映像,我们使用
mvn clean package dockerfile:build
。
The fun part is that my colleagues have no problem building docker image of Spring Boot service.有趣的是,我的同事在构建 Spring 引导服务的 docker 映像时没有问题。 And I get maven error message:
我收到 maven 错误消息:
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default-cli) on project 'foo': Could not build image: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('osxkeychain')
I tried to remove all maven repositories from .m2/repository
, restart docker, and remove all images.我试图从
.m2/repository
中删除所有 maven 存储库,重新启动 docker,然后删除所有图像。
Later I tried to run mvn clean package dockerfile:build
in to two separate commands:后来我尝试运行
mvn clean package dockerfile:build
in 到两个单独的命令:
mvn package
, then mvn package
,然后mvn docker:build
mvn package
passed, and mvn docker:build
failed with the same error as shown above. mvn package
已通过,并且mvn docker:build
失败,出现与上图相同的错误。
Maven version 3.5.4
, Docker version 18.06.1-ce, build e68fc7a
, OS: macOS mojave Maven 版本
3.5.4
,Docker 版本18.06.1-ce, build e68fc7a
,操作系统:macOS mojave
I even tried to restart my PC hoping that it will fix it...我什至试图重新启动我的电脑,希望它能修复它......
Edited: Here is the maven pom plugin dockerfile-maven-plugin
编辑:这是 maven pom 插件
dockerfile-maven-plugin
...
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>${project.artifactId}</repository>
</configuration>
</plugin>
...
Edit 2:编辑2:
Full error message:完整的错误信息:
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default) on project spring-boot-service: Could not build image: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('swarm')
[ERROR] at [Source: N/A; line: -1, column: -1] (through reference chain: java.util.LinkedHashMap["stackOrchestrator"])
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Edit 3:编辑3:
docker-compose.yml docker-compose.yml
wrapper:
image: spring-boot-service:latest
ports:
- "8080:8080"
expose:
- "8080"
links:
- db
- another-service
Solved:解决了:
In my case it was wrong version of dockerfile-maven-plugin
.就我而言,这是
dockerfile-maven-plugin
错误版本。 I used 1.3.6
, and 1.4.7
fixed the problem.我使用了
1.3.6
,而1.4.7
解决了这个问题。
Update: One more thing!更新:还有一件事!
Make sure when mvn
finish build naming is correct, for example:确保
mvn
finish build 命名时正确,例如:
[INFO] Successfully built **spring-boot-service:0.0.1-SNAPSHOT**
And docker-compose.yml
should look like this: docker-compose.yml
应该是这样的:
...
wrapper:
image: **spring-boot-service:0.0.1-SNAPSHOT**
...
Here is the dockerfile-maven-plugin config:这是dockerfile-maven-plugin配置:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${dockerfile-maven-plugin.version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
NOTE: use the latest released version 1.4.7注意:使用最新发布的版本1.4.7
This configures the plugin to build and push your image with a single command :这将插件配置为使用单个命令构建和推送您的图像:
$ mvn clean deploy
If you only want to build the Docker image, run:如果您只想构建 Docker 镜像,请运行:
$ mvn clean package
Solution:解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.