gpt4 book ai didi

java - 如何修改Jenkins官方Docker镜像中的Java内存?

转载 作者:行者123 更新时间:2023-12-01 18:27:39 26 4
gpt4 key购买 nike

我正在使用 jenkins 官方 docker 镜像

docker pull jenkins/jenkins:lts

我正在尝试优化 Xmx/Xms 内存配置,但没有成功。使用 JVM 选项运行容器会导致错误:

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

有什么想法吗?谢谢

最佳答案

按照 "Passing JVM parameters" docs 使用 JAVA_OPTS 环境变量。您需要设置-Xmx选项:

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 :

关于java - 如何修改Jenkins官方Docker镜像中的Java内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60208127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com