Unable to cache maven dependency in docker image

  docker, docker-maven-plugin, dockerfile, maven

I am using the sh file which contains all the maven configuration, secret keys, maven command. when I run the container it downloads the dependency again and again everytime, it is unable to cache the dependency.

Here is how my Dockerfile looks like :

#MVN as build tool
FROM docker.hub.com/maven:3.5.3-jdk-8

#Settings.xml for downloading dependencies from nexus repository
ARG MVN_SETTINGS=settings.xml

#Maven project pom
ARG MVN_POM=pom.xml

#Defining the current working repository
WORKDIR /usr/src/app

#Coping the settings.xml into working directory
COPY ${MVN_SETTINGS} settings.xml

#Coping the pom.xml into working directory
COPY ${MVN_POM} pom.xml

#Download the package and make it cached in docker image
RUN mvn -B -f ./pom.xml -s settings.xml dependency:resolve-plugins dependency:resolve

#Coping the source code into working repository
COPY  src .

COPY  Test.sh .

#Execute permission
RUN chmod a+x Test.sh

#Entry point for docker container
CMD ./Test.sh

Here is the Test.sh file

mvn test -DtestSuite=src/test/resources/suites/Suite.xml

When I create the docker image and run the container it downloads the dependency, again and again, every time I run it.

Source: Docker Questions