Skip to content

Minecraft (Java) Server in Container Manager on a Synology NAS

Important or Recent Updates
Historic UpdatesDate
Guide refreshed and updated for Container Manager22/07/2023
Also added a new section on how to open up Remote Play using your own address. 02/10/2023
Added additional security option to the compose to restrict the container from gaining new privileges also made the additional java variable as optional.25/10/2023
Updated with additional compose information to enable the interactive shell, so commands can be issued to the server, also removed the table relating to versions and linked to the official version with all tags. Amended instructions accordingly.12/07/2024
Removed the user defined bridge ‘synobridge’ as it is not really required for this setup as the container will create its own isolated bridge13/07/2024
Historic updates.

In this guide I am going to take you through the steps to get a Minecraft JAVA server up and running in Docker on a Synology NAS. If you are looking to host a server for a Console or Mobile you will want to see my Bedrock Edition guide.

Just an initial warning, Minecraft loves RAM! The more you can feed it the better the performance you will see. So if you are setting this up on a base model Synology with 2 GB of RAM expect performance issues!

The fantastic documentation on how to use the server once it is running can be found here

https://docker-minecraft-server.readthedocs.io/en/latest/

Let’s Begin

In order for you to successfully use this guide please complete the setting up a docker user guide.

As Container Manager now supports using Docker Compose in the UI we will be using it as it will save you lots of time and steps!

What on earth is a Docker Compose?
Docker Compose allows us to define how Docker should set up one or more containers within a single configuration file. This file is yaml formatted and Container Manager uses the Projects feature to manage them.


Folder Setup

First we need to set up a couple of folders to store our World and config files.

Using File Station create the following folders.

Folders
/docker/minecraftjava
/docker/projects/minecraftjava-compose

Container Set Up

Next we are going to set up a ‘Project’ in Container Manager. Open up Container Manager and click on Project, then on the right-hand side click ‘Create’.

In the next screen we will set up our General Settings.

SectionSetting
Project Name:minecraftjava
Path:/docker/projects/minecraftjava-compose
Source:Create docker-compose.yml

Next we are going to drop in our docker compose configuration, copy all the code in the box below and paste it into line ‘1’ just like the screenshot. (Yes line 16 is massive!)

YAML
services:
  spigotserver:
    image: itzg/minecraft-server:tag #edit this line as per the tag section
    container_name: minecraft
    environment:
      - UID=1234 #CHANGE_TO_YOUR_UID
      - GID=65432 #CHANGE_TO_YOUR_GID
      - EULA=TRUE
      - MEMORY=2G
      - TYPE=SPIGOT
      - VERSION=LATEST
      - LEVEL=world
      - SERVER_PORT=25565 #leave me
      - ONLINE_MODE=FALSE
      - SERVER_NAME=NAME OF YOUR SERVER
#      - JVM_XX_OPTS= #optional see below
    volumes:
      - /volume1/docker/minecraftjava:/data:rw
    ports:
      - 25565:25565/tcp
      - 25565:25565/udp
#      - 25575:25575 optional rcon port see warning below
    stdin_open: true
    tty: true
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped

Editing the Config and Environment Variables

Let’s make some edits to the compose in order to customise the server, I am covering the basics here, ITZG has great information over on the documentation which covers the many additional variables you can tweak!

Please keep in mind that yaml formatting is very specific, so keep things lined up as per the original!

Tags

First lets decide which version of the container we want as different versions of Minecraft require different JAVA versions.

In order to get the right version of Java for the version of Minecraft you want to run it involves editing the container tag. There are lots of versions to select see this really handy table in the documentation

https://docker-minecraft-server.readthedocs.io/en/latest/versions/java/#image-tags

Once you know the correct tag amend the image line accordingly for example:

image: itzg/minecraft-server:java21

We are now going to amend some key variables to make sure the container has access to our folders and setup some basic server config.

The values below go after the = on the appropriate line.

Please note if you decide to enable the RCON Port please change the default password especially if you open your server up to the Internet otherwise you will get hacked! See the GitHub for more details.

VariableValueComment
UIDChange it to the UID you obtained earlier in the first setup guides
GIDChange it to the GID you obtained earlier in the first setup guides
EULATRUEThis accepts the Minecraft EULA, without this the server will not run
MEMORY2GAmend the number to the amount of memory you want to allocate to the server this will depend on your system or server type you are running, generally more = better!
TYPEVANILLA
BUKKIT
SPIGOT
PAPER
TUINITY
MAGMA
MOHIST
CATSERVER
CURSEFORGE
SPONGEVANILLA
FABRIC
Choose a version from the list
VERSIONLATESTYou can change this to any a specific version if you want e.g 1.13
LEVELWORLDThis is what the world folder will be called when saved, so change to help identify if you decide to set up multiple worlds
ONLINE_MODEFALSEChange this to TRUE if you want to register the server with the Mincraft mothership keep in mind you will need a legit version of Minecraft to play on the server if this is enabled!
SERVER_NAMEGive it a nice name!
JVM_XX_OPTS-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15

I obtained these from a lot of digging around for optimising server JAVA performance you are free to edit or use them.
The basics

Once you have made all your required edits click ‘Next’

Nothing to change on the next screen click ‘Next’ again..

On the final screen just click ‘Done’ and you will see a new window appear which will kick of downloading of the required container image and configure your server.

Server startup time

The first time the server launches it may take a few minutes for the server files to download and the world to be generated. You can track the progress by going into the ‘Containers’ tab and clicking on details for the Minecraft container, then either viewing the terminal or log tabs.

After a few minutes you should be able to connect to your server using the IP of your NAS using port 25565

(Optional Extra for Remote Play)

So your friends have an easy way to play remotely lets set up an address for them to connect to, please note that the section below opens port 443 however you will also need to forward port 25565.

External Access

You have some choices when it comes to making your new container accessible from outside your home network, these come with different levels of security and convenience. This mini section is generic but covers the basics of getting this guide up and running and is entirely optional.

  • Synology’s DDNS (Dynamic Domain Name System) with a TLS Certificate and Reverse Proxy
    This is useful if you have some family members or friends that need access to something like Overseerr or Jellyseer and is covered below.

  • Tailscale or Wireguard VPN
    If just you are accessing these services, and you don’t want to expose them to the internet this would be the more secure choice. See my other separate guides.

  • Cloudflare Tunnels
    I don’t currently use these, so I would recommend watching the Wundertech guide on how they work.

A note on Double NAT or CGNAT
Unfortunately more ISPs are moving to these methods of address allocation as the IPv4 address space is getting low on available addresses. If your ISP is doing this your choices are more limited.

You can test if this is the case by checking the WAN IP on your Router/Modem settings and then comparing it to the one shown on portchecker.co. If they are different you are likely Double NAT and will either need to see if you can pay your ISP for a standard IPv4 address or use Tailscale or Cloudflare Tunnels for access.

Using the built-in tools on DSM

The first step of this process is to forward port 443 on your Router to your NAS IP Address, how you do this will depend on your router model, so please refer to its manual.

Router (External):443 > NASIP (Internal):443

Next make sure you have registered for a Synology Account as we are going to be using their DDNS service. https://account.synology.com/en-uk/register/ If you already have this set up move to the next step.

DDNS (Dynamic Domain Name System)

A DDNS address allows you to get external access to your container via an address provided by Synology, this is useful on home internet connections where your ISP will change your IP address on a semi-regular basis.

In the DSM Control panel go to ‘External Access’ and then to the ‘DDNS’ tab

Click on ‘Add’, then fill out the following sections.

SectionValue
Service ProviderSynology
HostnameThis will be the unique address just for you so keep the name generic.
minecraft.synology.me = BAD
myawesomenas.synology,me =GOOD
Email:Log into your Synology account
External Address (IPv4)This should be filled in automatically
External Address (IPv6)This should be filled in automatically if your ISP is using IPv6
Get a Cert from Let’s EncryptTick this box
Enable HeartbeatTick this box

Now press OK, DSM will apply your settings. It can take a few moments to set up and the DSM interface will refresh. You will likely receive a certificate error which you will need to accept to get back into DSM.

Reverse Proxy

We are going to set up a reverse proxy subdomain for the address you just register. This means you and your users can access the container without using a port number as it will route all traffic through the secure 443 port.

Go back into the Control Panel and access the ‘Login Portal’ then in the ‘Advanced’ tab click ‘Reverse Proxy’ and then click on ‘Create’.

We are now going to enter some rules, so when you or your users access the URL specified the request will automatically be sent to the containers web UI.

Use the settings below, you will need to amend the Hostname sections in line with the hostname you registered earlier, and the IP of your NAS.

SettingValue
Reverse Proxy Name:Give it a meaningful name in line with the container you are setting up.
Protocol:HTTPS
Hostname:containername.xxx.synology.me
containername‘ will be the name you want to use to access this container
.xxx.synology.me‘ will be the exact name you registered earlier
Port:443
Protocol:HTTP
Hostname:‘localhost’ or your NAS IP address
Port:The UI Port Number from the yaml in the guide you are following

On the second tab ‘Custom Header’ click on Create then WebSocket, this will add two entries for WebSockets to function correctly, you can now press save.

You should now be able to access the web UI of the container by going to the address you just set up in the reverse proxy, it will be a secure connection, and you should have no certificate errors.



Looking for some help, join our Discord community

If you are struggling with any steps in the guides or looking to branch out into other containers join our Discord community!

Buy me a beverage!

If you have found my site useful please consider pinging me a tip as it helps cover the cost of running things or just lets me stay hydrated. Plus 10% goes to the devs of the apps I do guides for every year.

Published inGaming 7.2

24 Comments

  1. PrivatePengu PrivatePengu

    Hello, and thank you so much for the help

    I’m struggling to get the server remotely accessible. It works locally just fine with the NAS’ local IP. However, I can’t connect to it remotely either through the DDNS name or just my external IP, even after port forwarding. I’m not sure if I’m portforwarding correctly – though it works on Plex – as using a port forward checker online says the port is closed.

    The error I get when trying to connect is “Connection timed out – getsockopt”.

    Do you know what the issue could be?

    • Dr_Frankenstein Dr_Frankenstein

      Hey PrivatePengu – Can you try also specifying the port number in the remote client as well to see if it helps.

      Double-check the port forward is 25565 > NAS both TCP and UDP as that should be all you need.

  2. Hi, I followed your tutorial (java server) and the server is up and running. Previously, I could open a terminal from the DSM webgui and make change such as /op and /whitelist on/add/list etc.
    For some reason, that does not work any more with this setup. It just offers me a black screen.

    I have tried adding /bin/sh or /bin/bash to the environment variables of the container to no avail.

    Also, when SSH-ing into the machine and running “docker exec -it bash” does not work.

    Any advice on what I could do to make such changes?

      • Willem Willem

        You rock, this works like a charm! 🙂 Let me see how I can get a well earned beverage your way.

        Alternatively, I noticed after setting an operator that the file ops.json had been updated. Might be an alternative way of settings the operator? Once you’re an operator, most other commands (at least the ones that I need) are available.

        {
        “uuid”: “abcd-1234-5678-9012-abcdefgh”,
        “name”: “Player_Name”,
        “level”: 4,
        “bypassesPlayerLimit”: false
        }

        • Dr_Frankenstein Dr_Frankenstein

          Thanks, there were issues a few month back with setting OPS due to some changes Microsoft had made. So good to know!

  3. Opie1Kenoby Opie1Kenoby

    Hello,

    I made all steps for the guide (including step 1/2/3 on docker / users/bridge)

    But i can’t connect to the server whith minecraft

    I add the server with DNS first time and IP second time, and same problem, that cannot connected to it.

    Any ideas ? (Ofc i’ve open corretly port on my router)

    Regards

    • Dr_Frankenstein Dr_Frankenstein

      If you are not able to connect via the IP address check that you don’t have the Firewall blocking anything, does the Server show as up when you add it to the Minecraft server list?

      • Opie1Kenoby Opie1Kenoby

        My bad, children’s didn’t inform me that it’s a different version between PC and mobile
        So…. Works fine withe the other tips

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

drfrankenstein.co.uk – writing Synology Docker Guides since 2016 – Join My Discord!