dependency-track
dependency-track copied to clipboard
JAVA_OPTIONS cannot be set in docker-compose.yml
Current Behavior
I am trying to limit the RAM the api server uses with docker-compose. Currently it uses 90% RAM which is not desired (I dont use docker swarm, therefore the resource limits do not work). When setting JAVA_OPTIONS or EXTRA_JAVA_OPTIONS in docker-compose.yml I Always get:
dtrack-apiserver_1 | Error: Could not find or load main class "-XX:+UseParallelGC
dtrack-apiserver_1 | Caused by: java.lang.ClassNotFoundException: "-XX:+UseParallelGC
I tried '- JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"' and ' - EXTRA_JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"'
Steps to Reproduce
Setting '- JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"' and ' - EXTRA_JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"'
Expected Behavior
RAM usage can be configured in docker-compose without using docker swarm
Dependency-Track Version
4.10.1
Dependency-Track Distribution
Container Image
Database Server
PostgreSQL
Database Server Version
14.3
Browser
Google Chrome
Checklist
- [X] I have read and understand the contributing guidelines
- [X] I have checked the existing issues for whether this defect was already reported
Hey @oers, it should work when you omit the double quotes ("
). So instead of:
environment:
- JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"
Use:
environment:
- JAVA_OPTIONS=-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0
Or, alternatively:
environment:
JAVA_OPTIONS: "-XX:+UseParallelGC -XX:MaxRAMPercentage=33.0"
Note that you can also limit the max heap size using absolute values with -Xmx
, e.g. -Xmx4g
would allow Java's heap to grow only up to 4GB.
Thanks that helped. EXTRA_JAVA_OPTIONS=-Xms8G -Xmx8G
The documentation in the docker-compose.yaml says:
Optional environmental variables to provide more JVM arguments to the API Server JVM, i.e. "-XX:ActiveProcessorCount=8"
With the quotes.
So its probably a documentatin issue.