私たちは、4人の小さなチームで働きます。当社は、当社のサービスを展開するためにドッキングウィンドウを使用して。サービスの一つは、Mavenのでドッキングウィンドウのイメージを構築した後に展開されているJavaの春ブーツプロジェクトです。春ブートサービスの我々の使用のドッキングウィンドウの画像を作成するにはmvn clean package dockerfile:build
。
楽しい部分は、私の同僚は、春ブートサービスのは問題の建物ドッキングウィンドウのイメージを持っていないということです。そして、私は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')
私はからすべてのMavenのリポジトリを削除しようとした.m2/repository
再起動のドッキングウィンドウ、およびすべての画像を削除します。
その後、私が実行しようとしたmvn clean package dockerfile:build
二つの別々のコマンドにして:
mvn package
、その後、mvn docker:build
mvn package
渡され、そしてmvn docker:build
上記のように同じエラーで失敗しました。
Mavenのバージョン3.5.4
、ドッカーバージョン18.06.1-ce, build e68fc7a
、OS:MacOSのモハーベ
私もそれはそれを修正することを期待して、私のPCを再起動しようとしました...
編集した:ここでは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:
ドッカー-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**
...
ここでdockerfile-のMavenプラグイン- configが:
<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
あなたが唯一のドッカーイメージを構築したい場合は、実行します。
$ mvn clean package