terrymanu commented on issue #36979:
URL: 
https://github.com/apache/shardingsphere/issues/36979#issuecomment-3477250637

   # Solution: JVM_OPTS Environment Variable Not Working in Docker
   
   ##  Root Cause Analysis
   
     After examining the start.sh script 
(distribution/proxy/src/main/resources/bin/start.sh), I identified the issue:
   
     - JVM_OPTS not processed: Line 86 defines JAVA_OPTS=" 
-Djava.awt.headless=true " but doesn't merge user-provided JVM_OPTS environment 
variable
     - Docker memory configuration logic: Lines 89-93 use CGROUP_MEM_OPTS in 
Docker environment, completely ignoring user-defined JVM_OPTS
   
   ##  Fix Solution
   
     Add the following code after line 86 in start.sh:
   
   ```
     # Merge user-defined JVM_OPTS
     if [ -n "${JVM_OPTS}" ]; then
         JAVA_OPTS="${JAVA_OPTS} ${JVM_OPTS}"
     fi
   ```
   
     This ensures that user-provided parameters like -Xmx256m -Xms256m -Xmn128m 
are properly applied to the Java process.
   
     We welcome you to contribute through the following steps:
   
     1. Modify source code
       - Update the start.sh file according to the solution above
       - Location: distribution/proxy/src/main/resources/bin/start.sh
     2. Local testing
       - Build a new Docker image
       - Test memory configuration using your original command:
   
     docker run -d \
     -v /root/server/proxy-b/conf:/opt/shardingsphere-proxy/conf \
     -v /root/server/proxy-b/ext-lib:/opt/shardingsphere-proxy/ext-lib \
     -e PORT=3308 -p13308:3308 \
     -e JVM_OPTS="-Xmx256m -Xms256m -Xmn128m" \
     --name server-proxxy-b \
     apache/shardingsphere-proxy:5.5.1
   
       - Verify that the container starts normally without the "Not enough 
space" error
     3. Submit PR
       - After successful testing, submit a Pull Request to the ShardingSphere 
repository
   
     This fix will help all users encountering similar issues, enabling 
JVM_OPTS to work properly in Docker environments.
   
     Are you interested in trying this fix solution?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to