[mc] Adjust mem with MEMORY and INIT_/MAX_MEMORY

For #126
This commit is contained in:
Geoff Bourne 2017-03-19 09:35:58 -05:00
parent 97040f61ed
commit bbe1533f91
3 changed files with 14 additions and 9 deletions

View File

@ -40,6 +40,6 @@ ENTRYPOINT [ "/start" ]
ENV UID=1000 GID=1000 \
MOTD="A Minecraft Server Powered by Docker" \
JVM_XX_OPTS="-XX:+UseG1GC" MAX_MEMORY="1G" \
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= ONLINE_MODE=TRUE CONSOLE=true

View File

@ -608,11 +608,16 @@ By default, server checks connecting players against Minecraft's account databas
### Memory Limit
By default the image declares a Java memory limit of 1 GB. That can be adjusted
higher (or lower) by setting the `MAX_MEMORY` environment variable. For example,
the following increases the memory limit to 8 GB:
By default, the image declares a Java initial and maximum memory limit of 1 GB. There are several
ways to adjust the memory settings:
docker run -e MAX_MEMORY=8G ...
* `MEMORY`, "1G" by default, can be used to adjust both initial (`Xms`) and max (`Xmx`)
memory settings of the JVM
* `INIT_MEMORY`, independently sets the initial heap size
* `MAX_MEMORY`, independently sets the max heap size
The values of all three are passed directly to the JVM and support format/units as
`<size>[g|G|m|M|k|K]`.
### /data ownership

View File

@ -491,10 +491,10 @@ else
EXTRA_ARGS=""
fi
if [[ ! -z $MAX_MEMORY ]]; then
# put prior JVM_OPTS at the end to give any memory settings there higher precedence
JVM_OPTS="-Xms${MAX_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
fi
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
echo "Setting initial memory to ${INIT_MEMORY:-${MEMORY}} and max to ${MAX_MEMORY:-${MEMORY}}"
JVM_OPTS="-Xms${INIT_MEMORY:-${MEMORY}} -Xmx${MAX_MEMORY:-${MEMORY}} ${JVM_OPTS}"
set -x
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
echo "Running FTB server modpack start ..."