我们在一个4人的小组里工作。我们使用码头部署我们的服务。其中一个服务是项目,它是在使用maven构建坞映像之后部署的。为了制作Spring服务的码头映像,我们使用了mvn clean package dockerfile:build。
有趣的是,我的同事们在建立Spring服务的码头形象方面没有问题。我得到了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')我试图从.m2/repository中删除所有maven存储库,重新启动docker,并删除所有映像。
后来,我尝试将mvn clean package dockerfile:build运行到两个单独的命令中:
mvn packagemvn docker:buildmvn package通过了,mvn docker:build失败了,与上面所示的错误相同。
Maven版本3.5.4,Docker版本18.06.1-ce, build e68fc7a,OS: macOS mojave
我甚至试图重新启动我的电脑,希望它能修好它.
编辑:这是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>
...编辑2:
完全错误消息:
[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
wrapper:
image: spring-boot-service:latest
ports:
- "8080:8080"
expose:
- "8080"
links:
- db
- another-service已解决:
在我的例子中,它是错误的dockerfile-maven-plugin版本。我使用1.3.6,1.4.7修复了这个问题。
多亏了鲍里斯!
更新:还有一件事!
例如,确保mvn完成生成命名是正确的:
[INFO] Successfully built **spring-boot-service:0.0.1-SNAPSHOT**docker-compose.yml应该是这样的:
...
wrapper:
image: **spring-boot-service:0.0.1-SNAPSHOT**
...发布于 2018-10-22 16:40:43
下面是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>注意:使用最新发布的1.4.7版本
这会将插件配置为使用单一命令构建和推送映像。
$ mvn clean deploy如果只想构建Docker映像,请运行:
$ mvn clean package发布于 2022-08-11 11:28:21
解决方案:
https://stackoverflow.com/questions/52933220
复制相似问题