Sign inSign up

bymatej/minecraft-server

By bymatej

•Updated over 1 year ago

Minecraft server with McMyAdmin2 and Spigot

Image
Web servers
2

2.8K

bymatej/minecraft-server repository overview

⁠minecraft-server

A Minecraft server with:

  • McMyAdmin
  • Ability to specify Mod/Flavor (Vanilla, Spigot, Forge) with ability to specify the Minecraft version
  • Fully configurable using environment variables
  • Volume to access all the configuration files later on

⁠Disclaimer

By using this Docker image you implicitly agree to the McMyAdmin's EULA.

You may read it here: https://mcmyadmin.com/licence.html⁠

I created this for my own personal use. I use it for fun on my "hacked" server. If you are not happy with the solution provided here, do one of the following:

  • Create a pull request with desired changes on this project and I will consider it
  • Fork this project and modify it
  • Write me an email at [email protected]⁠ and tell me what would you like me to change (don't expect me to do it if I don't think it's worth it, or if I don't find the time to do it)
  • Use it the way I use it and don't complain
  • Check other solutions, like this one, for example: https://github.com/tekgator/docker-mcmyadmin⁠

⁠System requirements

This heavily depends on:

  • your settings (world size, build height, view distance, number of players, etc.)
  • number of players currently playing
  • what is happening on the map (it is not the same to be alone in the desert, and be surrounded by 10 mobs; the latter requires a lot more work on the server side)

Here are the recommendations: https://minecraft.gamepedia.com/Server/Requirements/Dedicated#Console⁠

My server:

  • Lenovo Q190 (an old mini desktop PC)
  • 320 GB HDD (not SSD, unfortunately)
  • 4GB RAM (1600 MHz)
  • Intel Celeron CPU 1017U @ 1.60GHz (Dual Core)

So, it is a pretty low-end machine. I would recommend at least 2GB of RAM for the McMyAdmin (set using the JAVA_MEMORY environment variable). The settings I use are in the Recommended columns in the tables below.

It can run on 1GB of RAM, but it will be sluggish, and there will be a lot of ticks skipping. If you see the following entry in the log (in McMyAdmin console) it is not good: CONSOLE: thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running [####]ms behind, skipping [##] tick(s

⁠Running and stopping

Configuration and customization is done by running the default image command (the CMD in the dockerfile at the bottom of the file). Do not override the entrypoint, but also do not override the CMD.

⁠Run commands

This command will load most of the defaults, except the McMyAdmin password, Java memory and custom opts.

docker run -d \
    --name minecraft-server \
    -p 8080:8080 \
    -p 25565:25565 \
    --restart unless-stopped \
    --stop-timeout 30 \
    -v McMyAdmin:/McMyAdmin \
    -e MCMA_PASSWORD=StrongPa55! \
    -e JAVA_MEMORY=2048 \
    -e JAVA_CUSTOM_OPTS=-server \
    bymatej/minecraft-server
⁠Explanations

Official documentation: https://docs.docker.com/engine/reference/run/⁠

⁠docker run

The docker command that runs the image (creates the container out of the specified image).

⁠-d

This means "detached", so the run command is run in background.

⁠--name minecraft-server

Specifies the container name. You can change the minecraft-server to whatever you like.

⁠-p 8080:8080 and -p 25565:25565

Publishes a container's port to the host. So, container's port 8080 is published to port 8080 on the host.

In case, for example, the port 8080 is used by another app on your host, you can do the following: -p 8081:8080. This would publish 8080 in container to 8081 on the host. Your McMyAdmin web panel would be at http://localhost:8081 in that case.

More on ports can be found here: https://docs.docker.com/config/containers/container-networking/#published-ports⁠

⁠--restart unless-stopped

Restarts the container automatically, unless it is stopped intentionally. Good if the container crashes - it will restart automatically.

⁠--stop-timeout 30

Gives the container 30 seconds of timeout when stopping. Good for safe container stop.

⁠-v McMyAdmin:/McMyAdmin

Defines the volume. The /McMyAdmin is the folder in the container and the volume name is McMyAdmin.

⁠-e MCMA_PASSWORD=StrongPa55!

Defines the key-value pair for the environment variable. In this case, the key is MCMA_PASSWORD and the value is StrongPa55!. Multiple -e parameters can be added.

⁠bymatej/minecraft-server

Specified the image used. No tag is specified, so this is the same as bymatej/minecraft-server:latest.

⁠Create your own run command

Run your container with settings that fit your server the best.

⁠My run command
docker run -d \
    --name minecraft-server \
    -p 8080:8080 \
    -p 25565:25565 \
    --restart unless-stopped \
    --stop-timeout 30 \
    -v McMyAdmin:/McMyAdmin \
    -e MINECRAFT_FLAVOR=Forge \
    -e MINECRAFT_VERSION=1.12.2 \
    -e MCMA_PASSWORD=StrongPa55! \
    -e JAVA_MEMORY=3072 \
    -e JAVA_GC=-XX:+UseG1GC \
    -e JAVA_CUSTOM_OPTS=-server \
    -e ENABLE_COMMAND_BLOCK=true \
    -e LEVEL_NAME="World By Matej" \
    -e MOTD="A Minecraft Server by Matej" \
    -e DIFFICULTY=hard \
    -e MAX_PLAYERS=6 \
    -e ONLINE_MODE=false \
    -e VIEW_DISTANCE=5 \
    -e MAX_BUILD_HEIGHT=128 \
    -e PLAYER_IDLE_TIMEOUT=60 \
    -e SNOOPER_ENABLED=false \
    -e SPAWN_PROTECTION=10 \
    -e MAX_WORLD_SIZE=14999992 \
    bymatej/minecraft-server

The StrongPa55! is, obviously, not my actual password. :)

⁠Stopping the server

Steps:

  • Stop the Minecraft server in McMyAdmin web panel
  • Stop the container (if you want to)

Do not just stop the container without stopping the Minecraft server, so your world does not get corrupted.

To manage your containers, there is a nifty tool for that called Portainer. Check it out: https://www.portainer.io/⁠

⁠Environment variables

Variables are used to configure your McMyAdmin and Minecraft server on the first run (when executing docker run command). Subsequent container runs will skip the configuration. You don't want to "reconfigure" your server as the settings you changed in McMyAdmin after the first run would get replaced by the ones specified in the environment variables.

The Recommended value column (in some tables below) outlines the values that I personally use for my own server. This does not mean that the values I provided are in any sense better than the default ones. Apply the best values for your server. Do not bluntly copy/paste the values from others. Custom values are passed using environment variables on docker run command using -e parameter. Example: -e MCMA_PASSWORD=xyz

⁠Java version

You can specify the major Java version (8, 11, etc.). Recommended and default value is 8. You may specify 11 if your plugins need that exact version. Specifying an invalid value will cause errors and nothing will work.

VariableDefault valueDescription
JAVA_MAJOR_VERSION8Java major version

⁠Mod settings

This is only if you want to use Modded version of Minecraft. Specify the mod using MINECRAFT_FLAVOR environment variable. Options for the variable are:

  • Vanilla
  • Spigot
  • Forge

You can also specify the Minecraft version (1.12.2, 1.14, etc.) using the MINECRAFT_FLAVOR variable. The default value is latest. Specifying latest will use the latest version available.

If MINECRAFT_FLAVOR is set to Vanilla, the MINECRAFT_VERSION is ignored (for now). The installed version of Minecraft is the one that comes with McMyAdmin (possibly latest at the time of building the image). Installing other flavors/mods of Minecraft can also be configured in McMyAdmin GUI later on.

⁠Vanilla

To use Vanilla, the MINECRAFT_FLAVOR should be set to Vanilla. This is the default value. This settings triggers a script that downloads the Minecraft Server Jar file from https://mcversions.net/⁠

⁠Spigot

This is Spigot: https://www.spigotmc.org/⁠ To use Spigot build, the MINECRAFT_FLAVOR should be set to Spigot.

The environment variable MINECRAFT_VERSION is used when building Spigot jar file. Available versions are outlined here: https://www.spigotmc.org/wiki/buildtools/⁠

Important: Spigot is built on the first start of the container. This take a lot of time, so be patient. Check the container log by using docker logs command. Once you are past "Installing Spigot" the container will soon finish its entrypoint commands and your McMyAdmin will be ready.

⁠Forge

This is Forge: http://files.minecraftforge.net/⁠ To use the Forge build, the MINECRAFT_FLAVOR should be set to Forge.

The environment variable MINECRAFT_VERSION is used when getting the download link for Forge jar file.

VariableDefault valueDescription
MINECRAFT_FLAVORVanillaSpecify which Minecraft Flavor/Mod to install
MINECRAFT_VERSIONlatestMinecraft version

⁠McMyAdmin password

Initial password is set using the -setpass argument in the startup.sh script.

VariableDefault valueDescription
MCMA_PASSWORDnimdaPassword for McMyAdmin web application. Plese, do not use the default.

⁠McMyAdmin configuration

Environment variable names reflect the names of the properties in the McMyAdmin.conf file. Mappings between environment variable names, and names in the conf file, as well as the default values are outlined below. The recommended values are pretty much the values I personally use.

VariableName in conf fileDefault valueRecommended valueDescription
WEBSERVER_PORTWebserver.Port80808081Port on which MCMA web server is running
JAVA_PATHJava.PathdetectdetectPath to Java Runtime Environment
JAVA_MEMORYJava.Memory10243072Amount of RAM in MB avaliable for JVM (Java Virtual Machine)
JAVA_GCJava.GCdefault-XX:+UseG1GCJava Garbage Collector
JAVA_CUSTOM_OPTSJava.CustomOpts-serverExtra arguments to pass to Java when starting the Minecraft server

⁠Minecraft configuration

Environment variable names reflect the names of the properties in the server.properties file. Mappings between environment variable names, and names in the properties file, as well as the default values are outlined below. The recommended values are pretty much the values I personally use. All properties and their descriptions can be found here: https://minecraft.gamepedia.com/Server.properties#Java_Edition_3⁠

VariableName in properties fileDefault valueRecommended value
ENABLE_JMX_MONITORINGenable-jmx-monitoringfalsefalse
RCON_PORTrcon.port2557525575
LEVEL_SEEDlevel-seed
GAMEMODEgamemodesurvivalsurvival
ENABLE_COMMAND_BLOCKenable-command-blockfalsetrue
ENABLE_QUERYenable-queryfalsefalse
GENERATOR_SETTINGSgenerator-settings
LEVEL_NAMElevel-nameworldWorld By Matej
MOTDmotdA Minecraft ServerA Minecraft Server by Matej
QUERY_PORTquery.port2556525565
PVPpvptruetrue
GENERATE_STRUCTURESgenerate-structurestruetrue
DIFFICULTYdifficultyeasyhard
NETWORK_COMPRESSION_THRESHOLDnetwork-compression-threshold256256
MAX_TICK_TIMEmax-tick-time6000060000
MAX_PLAYERSmax-players206
USE_NATIVE_TRANSPORTuse-native-transporttruetrue
ONLINE_MODEonline-modetruefalse
ENABLE_STATUSenable-statustruetrue
ALLOW_FLIGHTallow-flightfalsefalse
BROADCAST_RCON_TO_OPSbroadcast-rcon-to-opstruetrue
VIEW_DISTANCEview-distance105
MAX_BUILD_HEIGHTmax-build-height256128
SERVER_IPserver-ip
ALLOW_NETHERallow-nethertruetrue
SERVER_PORTserver-port2556525565
ENABLE_RCONenable-rconfalsetrue
SYNC_CHUNK_WRITESsync-chunk-writestruetrue
OP_PERMISSION_LEVELop-permission-level44
PREVENT_PROXY_CONNECTIONSprevent-proxy-connectionsfalsefalse
RESOURCE_PACKresource-pack
ENTITY_BROADCAST_RANGE_PERCENTAGEentity-broadcast-range-percentage100100
RCON_PASSWORDrcon.password
PLAYER_IDLE_TIMEOUTplayer-idle-timeout060
FORCE_GAMEMODEforce-gamemodefalsefalse
RATE_LIMITrate-limit00
HARDCOREhardcorefalsefalse
WHITE_LISTwhite-listfalsefalse
BROADCAST_CONSOLE_TO_OPSbroadcast-console-to-opstruetrue
SPAWN_NPCSspawn-npcstruetrue
SPAWN_ANIMALSspawn-animalstruetrue
SNOOPER_ENABLEDsnooper-enabledtruefalse
FUNCTION_PERMISSION_LEVELfunction-permission-level22
LEVEL_TYPElevel-typedefaultdefault
SPAWN_MONSTERSspawn-monsterstruetrue
ENFORCE_WHITELISTenforce-whitelistfalsefalse
RESOURCE_PACK_SHA1resource-pack-sha1
SPAWN_PROTECTIONspawn-protection1610
MAX_WORLD_SIZEmax-world-size2999998414999992

⁠Resources and additional instructions

⁠Resources

Resources and technologies used:

⁠Minecraft and McMyAdmin additional instructions

⁠Installation
⁠Minecraft gameplay
⁠McMyAdmin additional configuration

⁠How I run my server

⁠Reasoning

I have several servers, but they are never on at the same time. The reason for that is:

  • lack of RAM on my server machine
  • ports clashing
  • there is no need for that, as I am always playing

If you have more RAM, you can run many containers on your machine.

As for the ports clashing... I am running my server on the port 8080 on the host machine. I cannot run multiple servers on the same port, obviously. I could use another port on host machine (for example, 8081), but then I need to forward it on my router. Port forwarding is easy when I am at my home (where my router is). However, I don't have any remote management settings enabled on it. Bottom line is - if I am not home I cannot spin up a new server on a new port. I could leave a range of ports open, but I simply don't want to do it.

Also, I am always playing on my servers. I don't manage a server that is open for everyone. It is for me and for fun with my family and friends.

⁠Steps to run the server

⁠Server #1 - Minecraft Forge version 1.12.2 with mods
⁠Mods I use

Mods used are:

More info here: https://github.com/bymatej/minecraft-java-server-install-script#mods⁠

⁠Steps I take
  1. Prepare docker run command to use Forge
  2. Execute docker run command
  3. Download all the JAR files from all the mods
  4. Upload them somewhere where I can download them using wget command (private hosting, dropbox, etc.)
  5. Go to Portainer and exec into the container where my server is (or I go to the host machine and execute docker exec -ti minecraft-server /bin/bash)
  6. Switch to the dockeruser user using su dockeruser command
  7. Go inside mods folder by using cd /McMyAdmin/Minecraft/mods command
  8. Run wget commands to download the mods from where I uploaded them. For example: wget https://www.dropbox.com/s/p22np06hizycall/vehicle-0.44.1-mc1.12.2.jar
  9. After all mods are downloaded I start my server on my McMyAdmin console
⁠Server #2 - Minecraft Vanilla latest version
⁠Steps I take
  1. Prepare your docker run command to use Vanilla
  2. Execute your docker run command
  3. Go to McMyAdmin console and start my server

Tag summary

Content type

Image

Digest

sha256:df00cabbd…

Size

512.9 MB

Last updated

over 1 year ago

docker pull bymatej/minecraft-server