Hello,
I tied to follow the spring tutorial to docker but got the following exception when trying to build the docker image:
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) @ app ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.449 s
[INFO] Finished at: 2018-04-30T13:25:27+02:00
[INFO] Final Memory: 56M/717M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project app: Exception caught: Must specify baseImage if dockerDirectory is null -> [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
My POM config:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>foo/${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
I don't know if it's relevant but I also hat do add the following to the maven settings.xml:
<pluginGroups>
<pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
Otherwise the project also failed to build.
My Dockerfile is in the root directory of the project and looks like this:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Thanks for the help!
I've had this problem, too. Have you solved it
Sadly, I have not. Currently, I am manually building the docker image but it would be really great to have this maven integration.
<executions>
<execution>
<id>default</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
You can try it out.
Note that the plugin you are using is not the one in this repo: https://github.com/spotify/docker-maven-plugin
Check the documentation of that plugin - you have to either supply info in the pom so that the plugin can generate a Dockerfile (such as baseImage), or specify a Dockerfile to use.
I've had this problem, too
Try this:
The issue was simple - the command is mvn clean package dockerfile:build and not mvn clean package docker:build
Thanks to Telax1985
PaulGobin you nailed it, after a lot of struggle this solution worked for me. If you can, can you explain whats the difference between the two. As in some places I used the later one and it also worked
Paul's solution helped me too. I had upgraded from docker-mavin-plugin to dockerfile-maven-plugin but didn't know enough to change the command-line parameter from docker:build to dockerfile:build.
good!
Most helpful comment
Try this:
The issue was simple - the command is mvn clean package dockerfile:build and not mvn clean package docker:build
Thanks to Telax1985