|Added Docker Compose details||03/05/2021|
This guide replaces the two previous guides on the site, they will be archived in due course.
In this guide I am going to take you through the steps to get a Minecraft server up and running. This applies to both a Vanilla and modded server.
We will be using DSM6 and the latest version of Docker at the time of writing. The server I run is now open to anyone who want’s to play, its usually up and running most of the time. You can see its status in the widget on the left of this page 🙂
Downloading the Container
Open up Docker within DSM and navigate to the ‘Registry’ tab and search for ITZG in the keyword box.within the results right click and download the ‘ITZG|Minecraft-Server’, When it asks which version number to download select ‘Latest’
Setting up a Docker User for Minecraft and Obtaining the PGID and PUID
In previous versions of this guide we used your default admin account for each container, this is not very secure so please now follow the separate setup guide and then head back here.
Setting up the container
Now we have downloaded the container and got hold of our user IDs we can move onto the next stage, where we will configure the Docker container. First go back into Docker and click on the ‘Image’ tab, in the list of your containers select the ITZG minecraft server, and click on ‘Launch’
You will be greeted with the initial setup screen, this is where you can start specifying some of your preferences.
As this is a Minecraft server it will likely use as much memory and CPU usage as you allow it, if you are running the server on a lower specification Synology machine you will probably want to set limits around the CPU priority and memory usage to ensure DSM is still usable when the server is running.
In this case I am leaving this as the defaults, you can always come back and tweak these settings later once the server is setup.
Next up we are going to setup some other parts, click on the ‘Advanced’ button.
On this first tab you can decide if you want to create a shortcut to the server on the DSM desktop and also if you want the server to start up automatically if you ever restart your Syno, this is useful if you don’t want to login to manually startup the server.
In the next tab we need to setup where we want the various Minecraft world files to reside, having these outside of the container will mean you can make backups of the entire server, great if someone decides to flood the map with Lava!
Personally, I setup folders for each of the containers I am running in the default Docker directory as this keeps things nice and tidy.
We are going to mount a single directory for this container, the internal “/data” directory to the NAS “/docker/minecraft” seen the screenshot to see exactly how this is laid out.
You do not need to adjust and settings in this tab.
By default docker will automatically assign external ports to your Docker container, however we will never know what they are until the container is launched and also they may change upon a reboot, so we will need to assign some specific ports.
In the case of this container Minecraft uses high value port number so it’s unlikely to clash with any other containers or ports already used by DSM. So we are just going to enter the same port numbers on the left hand column.
Environment Variables – PGID , PUID, Server Type and EULA
We are now going to set up the specific options for the server including what type of server you would like to run and even a specific version.
*Please note that you must not change the UID and GID options in the first red box.
First up Click on the + sign at the top of the options page, in the ‘Variable’ box type PGID and enter the value you obtained earlier, repeat this step for the PUID. (See screenshot)
In addition to this we have to accept the Minecraft EULA so you will add an additional variable called EULA with the value set to TRUE.
You can now specify the type of server you would like to run by amending the value next to the TYPE variable.
If you want to run a specific version of the server you can amend the VERSION variable from LATEST to for example 1.13
*Please note the screenshot below has been updated, as you can see after you run the server for the first time a lot of additional variables are automatically added. Ignore the GID and UID towards the top of this screenshot we only need to fill in the items at the bottom!
You have now completed the hard part of the guide, click on OK and you will be taken back to an overall summary screen, this is just a summary of the settings you have entered, just do a quick sanity check to make sure they are correct. if you want to launch the server immediately check the box and click on finish.
Server startup time
The first time the server is launched it may take a few minutes to start as the files are downloaded and the world in generated, this time will depend on how fast your Synology performs, you can track the progress by going into the ‘Containers’ tab and clicking on details, and then either viewing the terminal or log tabs.
All other server settings can be configured using the standard Minecraft server.properties file, I won’t be covering that here as there are extensive other guides out there.
You can use the below code saved as minecraft.yml to do the entire process above in one quick command via SSH.
version: "3.2" services: spigotserver: image: itzg/minecraft-server:latest container_name: minecraft environment: - UID=YOURPUID - GID=YOURPGID - JVM_XX_OPTS=-XX:+UseG1GC - MEMORY=2G - TYPE=SPIGOT - VERSION=LATEST - FORGEVERSION=RECOMMENDED - SPONGEBRANCH=STABLE - SPONGEVERSION= - FABRICVERSION=LATEST - LEVEL=world - PVP=true - DIFFICULTY=easy - ENABLE_RCON=true - RCON_PORT=25575 - RCON_PASSWORD= - LEVEL_TYPE=DEFAULT - SERVER_PORT=25565 - ONLINE_MODE=FALSE - SERVER_NAME=NAME OF YOUR SERVER - ENABLE_AUTOPAUSE=false - AUTOPAUSE_TIMEOUT_EST=3600 - AUTOPAUSE_TIMEOUT_KN=120 - AUTOPAUSE_TIMEOUT_INIT=600 - AUTOPAUSE_PERIOD=10 - REPLACE_ENV_VARIABLES=FALSE - ENV_VARIABLE_PREFIX=CFG_ - EULA=TRUE volumes: - /volume1/docker/minecraft:/data:rw ports: - 25565:25565/tcp - 25575:25575/tcp restart: unless-stopped
sudo docker-compose -f /volume1/docker/minecraft.yml up -d --remove-orphans