简体   繁体   English

未能执行目标 com.spotify:dockerfile-maven-plugin:1.3.6:build on project 'foo':无法构建映像:

[英]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解决了这个问题。

Thanks to Boris !感谢鲍里斯

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:解决方案:

  1. Go to docker desktop Go 转 docker 桌面
  2. Open settings打开设置
  3. Go to general and put tick on Expose daemon on tcp://localhost:2375 without TLS enter image description here Go 到一般并在 tcp://localhost:2375 上的 Expose daemon 上打勾,没有 TLS在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未能执行目标 com.spotify:docker-maven-plugin:1.2.1:build (build-image) - Failed to execute goal com.spotify:docker-maven-plugin:1.2.1:build (build-image) Maven 无法找到 com.spotify:dockerfile-maven-extension:1.4.3 的插件描述符 - Maven fails to find plugin descriptor for com.spotify:dockerfile-maven-extension:1.4.3 使用 spotify/dockerfile-maven-plugin 推送 docker hub 时出错 - Error pushing docker hub using spotify/dockerfile-maven-plugin spotify/dockerfile-maven 插件:无法构建映像:javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接 - spotify/dockerfile-maven plugin: Could not build image: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 构建 docker 镜像时出错,无法在项目上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) - Error while building docker image, Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2:build-image (default-cli) on project Maven 构建错误 - 无法执行目标 org.apache.maven.plugins:maven-assembly-plugin:2.5.5 - Maven build error - Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5 Maven 构建编译错误:无法在项目 Maven 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) - Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven 无法再编译Vaadin项目(无法执行目标com.vaadin:vaadin-maven-plugin) - Can't compile Vaadin project anymore ( Failed to execute goal com.vaadin:vaadin-maven-plugin ) Maven构建错误:无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile - Maven build error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile 无法使用 MAVEN 构建并出现错误 - 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile - Unable to Build using MAVEN with ERROR - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM