Compile With Docker Maven

docker maven images

1
docker pull 3-jdk-8
[link](https://hub.docker.com/_/maven)

mvn package 当前目录

1
2
3
4
docker run -it --rm --name my-maven-project \
-v "$(pwd)":/usr/src/mymaven \
-w /usr/src/mymaven maven:3-jdk-8 \
mvn clean package

mvn package 当前目录,并使用本地/data/m2目录的maven配置

1
2
3
4
5
docker run -it --rm --name maven-project-xxx \
-v /data/m2:/root/.m2 \
-v "$(pwd)":/usr/src/mvnp \
-w /usr/src/mvnp maven:3-jdk-8 \
mvn clean package

使用非root运行

1
docker run -v ~/.m2:/var/maven/.m2 -ti --rm -u 1000 -e MAVEN_CONFIG=/var/maven/.m2 maven mvn -Duser.home=/var/maven archetype:generate