Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build on project 'foo': Could not build image:

Domas A. :

We working in small team of 4 people. We using docker to deploy our services. One of the services is a java Spring Boot project which is deployed after building docker image with maven. To make docker image of Spring Boot service we use mvn clean package dockerfile:build.

The fun part is that my colleagues have no problem building docker image of Spring Boot service. And I get maven error message:

[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.

Later I tried to run mvn clean package dockerfile:build in to two separate commands:

  • mvn package, then
  • mvn docker:build

mvn package passed, and mvn docker:build failed with the same error as shown above.

Maven version 3.5.4, Docker version 18.06.1-ce, build e68fc7a, OS: 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

...
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.3.6</version>
    <configuration>
        <repository>${project.artifactId}</repository>
    </configuration>
</plugin>
...

Edit 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:

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. I used 1.3.6, and 1.4.7 fixed the problem.

Thanks to Boris!

Update: One more thing!

Make sure when mvn finish build naming is correct, for example:

[INFO] Successfully built **spring-boot-service:0.0.1-SNAPSHOT**

And docker-compose.yml should look like this:

...
wrapper:
  image: **spring-boot-service:0.0.1-SNAPSHOT**
...
Boris :

Here is the dockerfile-maven-plugin 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>

NOTE: use the latest released version 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:

$ mvn clean package

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=98560&siteId=1