Skip to content

tomaszsimon/docker-jvm-memory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Understanding Docker and JVM memory

Create a shared Maven repository

docker volume create --name maven-repo

Run with no memory limits, no problem

docker run -it -v maven-repo:/root/.m2 --name mvn-test -v `pwd`:/usr/src/app maven:3-onbuild mvn package
docker rm mvn-test

Limit memory to 192m

docker run -it -m 192m -v maven-repo:/root/.m2 --name mvn-test -v `pwd`:/usr/src/app maven:3-onbuild mvn -o package
docker inspect mvn-test | head -n 25
docker rm mvn-test

Limit memory to 192m and set Xmx

docker run --rm -it -m 192m -e MAVEN_OPTS=-Xmx192m -v maven-repo:/root/.m2 --name mvn-test -v `pwd`:/usr/src/app maven:3-onbuild mvn -o package
docker rm mvn-test

Limit memory to 192m and set Xmx, with surefire running in the default forked mode

docker run --rm -it -m 192m -e MAVEN_OPTS=-Xmx192m -v maven-repo:/root/.m2 --name mvn-test -v `pwd`:/usr/src/app maven:3-onbuild mvn -f pom-fork.xml -o package
docker rm mvn-test

Limit memory to 192m and set Xmx in _JAVA_OPTIONS, with surefire running in the default forked mode

docker run --rm -it -m 192m -e _JAVA_OPTIONS=-Xmx192m -v maven-repo:/root/.m2 --name mvn-test -v `pwd`:/usr/src/app maven:3-onbuild mvn -f pom-fork.xml -o package
docker rm mvn-test

About

Docker example to understand JVM memory

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%