Unable to locate the project artifact during docker:build
See original GitHub issueI am unable to really figure out which relative path is used by docker during the build process. Hence this request.
The docker:build
always fails with the output
[INFO] --- docker-maven-plugin:0.13.9:build (default-cli) @ sample-spring-boot-docker ---
[INFO] Copying files to /home/vagrant/SampleApp/greeting-service/target/docker/greeting-service/build/maven
[INFO] Building tar: /home/vagrant/SampleApp/greeting-service/target/docker/greeting-service/tmp/docker-build.tar
[ERROR] DOCKER> Error building image: lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[ERROR] DOCKER> lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[ERROR] DOCKER> lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
The pom.xml
, Dockerfile
and find
output is given below:
<plugin>
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.13.9</version>
<configuration>
<images>
<image>
<name>greeting-service</name>
<build>
<assembly>
<descriptorRef>artifact</descriptorRef>
<dockerFileDir>.</dockerFileDir>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>
FROM somebaseimage
ADD sample-spring-boot-docker-0.1.0.jar app.jar
....
vagrant@greeting-service-host:~/SampleApp/greeting-service/target/docker$ find .
.
./greeting-service
./greeting-service/build
./greeting-service/build/maven
./greeting-service/build/maven/sample-spring-boot-docker-0.1.0.jar
./greeting-service/tmp
./greeting-service/tmp/docker-build.tar
./greeting-service/work
Issue Analytics
- State:
- Created 8 years ago
- Comments:7
Top Results From Across the Web
Multi Module Maven Project and Docker: Cannot find artifact?
1-SNAPSHOT seems to be private, your Maven command inside Docker build needs to be able to either download it from private repository or...
Read more >Artifacts file in Docker volumen not found - gitlab-runner
When I look into the runners file system I find the generated file under /builds/team/project/test.json for example.
Read more >Quickstart: Store Docker container images in Artifact Registry
Artifact Registry provides a single location for managing private packages and Docker container images. This quickstart shows you how to:.
Read more >CLI for JFrog Artifactory - JFrog CLI
Download all artifacts located in the my-local-repo repository with a jar extension to the all-my-frogs folder under the current directory. ? $ ...
Read more >Jib Build - Skaffold
To use Jib, add a jib field to each artifact you specify in the artifacts part ... To build a Maven multi-module project,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nitin-tiwari
pom.xml
Dockerfile
You have to distinguish between two build modes:
dockerFileDir
Both are currently more or less orthogonal (however there is work to let a Dockerfile reference the assembly defined in the pom).
In your example you are using more or less both which at least seems to copy the assembly in the build directory. When you then use
dockerFileDir
then thebuild
dir is the context dir for the Docker build. So you should useADD maven/sample-spring-boot-docker-0.1.0.jar app.jar
in the Dockerfile.However, this approach is not recommended, since you would need to update the version number all the time. Instead you should use an assembly which maps the artifact name to a fixed outputFileName (this can be done in a custom assembly descriptor). Also, you could use a basedir
/
in the plugin’s build>assembly configuration so that it will be automatically added and you wouldn’t need to specify a dockerfile dir.Do you have the full example as a github project ? If so, I could send you a PR with my suggestions.