I am creating a Docker image from this Docker file:
FROM maven:3.3.3-jdk-8 MAINTAINER Mickael BARON ADD pom.xml /work/pom.xml WORKDIR /work RUN mvn dependency:go-offline --fail-never ADD ["src", "/work/src"] RUN ["mvn", "package"]
With this Dockerfile, I force download dependencies before packing my Java project. This way, I do not need to reload the dependencies every time I change the file from the src directory.
But there is a problem, and this problem depends on the version of Maven (the base image). In fact, the dependencies are loaded, but they are not stored in the ~ / .m2 directory of the container. He is empty. Thus, when I change some source file, all dependencies are reloaded.
However, I noticed that if I change the version of Maven from the base image (e.g. FROM maven:3.2.5-jdk-8 ), it will work.
Very strange, isn't it?
maven docker dependencies dockerfile
Mickael baron
source share