Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify Java Memory In Jenkins official Docker image?

I'm using jenkins official docker image

docker pull jenkins/jenkins:lts

I'm trying to optimise the Xmx/Xms memory configuration but without success. Running the container with JVM options causes an error:

docker run jenkins/jenkins:lts --Xmx512m 

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at Main._main(Main.java:375)
        at Main.main(Main.java:151)
Caused by: java.lang.IllegalArgumentException: Unrecognized option: --Xmx512m
        at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:52)
        at winstone.Launcher.getArgsFromCommandLine(Launcher.java:371)
        at winstone.Launcher.main(Launcher.java:342)
        ... 6 more

Any ideas ? Thanks

like image 363
isoman Avatar asked Feb 09 '26 22:02

isoman


1 Answers

Use JAVA_OPTS environment variable as per the "Passing JVM parameters" docs. You need to set the -Xmx option:

docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS=-Xmx1g jenkins/jenkins:lts

You might need to customize the JVM running Jenkins, typically to pass system properties (list of props) or tweak heap memory settings. Use JAVA_OPTS environment variable for this purpose :

like image 156
Karol Dowbecki Avatar answered Feb 12 '26 16:02

Karol Dowbecki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!