Issue
I have to build a docker image and package java application using maven in the docker container but when I run the build process all is going fine but all maven dependencies downloading from maven remote repo.
That is my docker file:
FROM ubuntu_img
CMD ./mvnw -s .mvn/settings.xml --batch-mode clean package
How can I configure docker or maven for downloading dependencies from maven local repository located on my laptop?
Solution
At first, you need to attach the directory of your existing local Maven repository into the Docker container:
VOLUME ["/home/<user>/.m2", "/root/.m2"]
Then you need to tell Maven (inside your container) to use this directory as a local repository.
setting.xml
<settings ...>
<localRepository>/root/.m2</localRepository>
...
</settings>
Answered By - zappee
Answer Checked By - Timothy Miller (JavaFixing Admin)