使用以下命令,我使用spring-boot-maven-plugin从我的应用程序中构建了一个坞映像:
spring-boot::build-image我需要用这个jvm参数来更改jvm直接内存的默认大小(默认值为10m):
-XX:MaxDirectMemorySize=64M这是我在应用程序的pom.xml中拼命尝试的尝试,在那里我尝试了我脑海中的每一件事:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<jvmArguments>-XX:MaxDirectMemorySize=64M</jvmArguments>
<environmentVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</environmentVariables>
<systemPropertyVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
</image>
<excludeDevtools>true</excludeDevtools>
<systemPropertyVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</systemPropertyVariables>
<environmentVariables>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
<JAVA_OPTS>-XX:MaxDirectMemorySize=64M</JAVA_OPTS>
</environmentVariables>
<jvmArguments>-XX:MaxDirectMemorySize=64M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</jvmArguments>
</configuration>
</plugin>但是直接内存仍然设置为10M :(当应用程序启动时,我可以在日志文件中看到这一点:
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -agentpath:/layers/paketo-buildpacks_bellsoft-liberica/jvmkill/jvmkill-1.16.0-RELEASE.so=printHeapHistogram=1 -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx11521920K -XX:MaxMetaspaceSize=144375K -XX:ReservedCodeCacheSize=240M -Xss1M -Dorg.springframework.cloud.bindings.boot.enable=true有人能告诉我我做错了什么吗?
备注:
弹簧启动:2.3.7
当我用-e手动运行docker映像时,jvm参数的更改是有效的:
docker run -e JAVA_TOOL_OPTIONS=-XX:MaxDirectMemorySize=64M docker.io/example/app-name:0.0.1这个mvn插件正在使用Buildpack来创建码头映像:
https://paketo.io/docs/buildpacks/language-family-buildpacks/java/#about-the-jvm
更新:
根据文档,这应该是可行的解决方案,但它不是:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
<env>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
</env>
</image>
</configuration>发布于 2021-01-13 22:15:14
这是一个关于如何使运行时env“粘稠”的工作解决方案:
....
<image>
<name>docker.io/example/${project.artifactId}:${project.version}</name>
<env>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS>
</env>
</image>
...spring-boot-maven-plugin正在使用paketo buildpack:。
医生:https://github.com/paketo-buildpacks/environment-variables
发布于 2021-01-13 21:38:12
这取决于你在这里的目标。听起来,当应用程序运行时,您想要更改容器中的最大直接内存,所以您应该只做这里显示的工作(以及文档中列出的内容)。
docker run -e JAVA_TOOL_OPTIONS=-XX:MaxDirectMemorySize=64M docker.io/example/app-name:0.0.1
您所引用的doc链接是关于在运行时配置选项的,这就是您对env变量所做的操作。
发布于 2021-08-04 01:51:42
对于在Mac + Spring的构建映像上使用Docker的任何人,请注意,在编写Docker默认设置时,Mac上的Docker是一个2GB的VM映像,它运行Linux,Docker在这个linux中运行。
对于当前的Spring2.3.X默认的Pareto生成器,这将导致一个可使用大约300 me的坞映像,但是根据内存计算器,一个相当简单的Spring应用程序(对我来说)需要大约600 me。
因此,无论maxDirectMemorySize的价值如何,它都是行不通的。一旦我提高了对接者VM可用的mem,它就工作得很好。
https://stackoverflow.com/questions/65709080
复制相似问题