diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index cdd787e1..195476e2 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -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 diff --git a/minecraft-server/README.md b/minecraft-server/README.md index f2495217..18448e62 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -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 +`[g|G|m|M|k|K]`. ### /data ownership diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index b6cebdfa..bd784be1 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -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 ..."