首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未能在项目“foo”上执行目标com.spotify:dockerfile-maven-plugin:1.3.6:build :无法生成映像:

未能在项目“foo”上执行目标com.spotify:dockerfile-maven-plugin:1.3.6:build :无法生成映像:
EN

Stack Overflow用户
提问于 2018-10-22 15:49:48
回答 2查看 13K关注 0票数 8

我们在一个4人的小组里工作。我们使用码头部署我们的服务。其中一个服务是项目,它是在使用maven构建坞映像之后部署的。为了制作Spring服务的码头映像,我们使用了mvn clean package dockerfile:build

有趣的是,我的同事们在建立Spring服务的码头形象方面没有问题。我得到了maven错误消息:

代码语言:javascript
运行
复制
[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')

我试图从.m2/repository中删除所有maven存储库,重新启动docker,并删除所有映像。

后来,我尝试将mvn clean package dockerfile:build运行到两个单独的命令中:

  • 然后是mvn package
  • mvn docker:build

mvn package通过了,mvn docker:build失败了,与上面所示的错误相同。

Maven版本3.5.4,Docker版本18.06.1-ce, build e68fc7a,OS: macOS mojave

我甚至试图重新启动我的电脑,希望它能修好它.

编辑:这是maven pom插件dockerfile-maven-plugin

代码语言:javascript
运行
复制
...
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.3.6</version>
    <configuration>
        <repository>${project.artifactId}</repository>
    </configuration>
</plugin>
...

编辑2:

完全错误消息:

代码语言:javascript
运行
复制
[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

编辑3:

docker-compose.yml

代码语言:javascript
运行
复制
wrapper:
  image: spring-boot-service:latest
ports:
  - "8080:8080"
expose:
  - "8080"
links:
  - db
  - another-service

已解决:

在我的例子中,它是错误的dockerfile-maven-plugin版本。我使用1.3.61.4.7修复了这个问题。

多亏了鲍里斯

更新:还有一件事!

例如,确保mvn完成生成命名是正确的:

代码语言:javascript
运行
复制
[INFO] Successfully built **spring-boot-service:0.0.1-SNAPSHOT**

docker-compose.yml应该是这样的:

代码语言:javascript
运行
复制
...
wrapper:
  image: **spring-boot-service:0.0.1-SNAPSHOT**
...
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-22 16:40:43

下面是dockerfile-maven-plugin配置:

代码语言:javascript
运行
复制
<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>

注意:使用最新发布的1.4.7版本

这会将插件配置为使用单一命令构建和推送映像。

代码语言:javascript
运行
复制
$ mvn clean deploy

如果只想构建Docker映像,请运行:

代码语言:javascript
运行
复制
$ mvn clean package
票数 9
EN

Stack Overflow用户

发布于 2022-08-11 11:28:21

解决方案:

  1. 转到码头桌面
  2. 打开设置
  3. 转到general,并在tcp://localhost:2375上显示守护进程,而不使用TLS 在这里输入图像描述
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52933220

复制
相关文章

相似问题

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