Jordan Herzstein

Jordan Herzstein

Minecraft Java Edition Server For Free

#vps #technology #oracle #tutorial #minecraft

Preamble

So I’ve been playing around recently with a free Oracle VPS, which if you want to play around with virtual private servers running Linux, don’t care about the company, and don’t have much cash to spare; Oracle has by far the most generous forever-free tier cloud offerings I’ve come across. For no cost whatsoever you too can run a 24GB of ram and 4 CPU cores VPS, and additionally you have to explicitly upgrade your account to access paid features, so you won’t be getting any unexpected charges. Just be wary that if your server is not active Oracle can shut down your server, and from what I’ve heard their customer service isn’t great. If you want to get into hosting your own VPS, I would go for a service that has a more consistant pricing structure, such as Hetzner.

Anyway to get away from that tangent, I was having some analysis-paralysis as to what kind of project I should use it for and finally decided to spin up a minecraft server as it would be something I’d be able to share with friends and family. It makes it all the more tragic, however, that I have not used Mincraft in about 4 years, meaning that I missed the train on transitioning my Mojang account over to Microsoft, and I no longer have access to an account to install and play Minecraft. Given that my parents I had already paid for a copy over a decade ago at this point for the game I should own, I think there is one word that can aptly describe what has been done here it’s just leaving my mind at the moment… Oh yes, that’s stealing. Forced arbitration is one thing, but even Youtube is still able to offer old Youtube accounts to upgrade to Google accounts (The Lady from UN 2021).

Anyway, it isn’t the end of the world, I will find a way to play Minecraft one way or another, even if that means repaying for a game I should already have ownership over. However, if you own minecraft you shouldn’t have to pay anything at all to play on a server with your friends, and it doesn’t have to be difficult to deploy as well. This guide will outline how to deploy a minecraft server using docker compose on an Oracle VPS in the way that I have.

The Guide

The following guide assumes you already have an Oracle VPS you can ssh into running an apt-based operating system such as Ubuntu 22.04, the operating system I will be using for this guide. I recommend following the guide that exists on FMHY to set one up (Cevoj35548 2022).

Installing docker for Ubuntu

First update your packages list.

sudo apt update

Install the proper dependencies.

sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release

Download the GPG key for Docker to sign packages.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Add the Docker repository to your sources

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker engine, docker compose, and their dependencies.

sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Create a new docker user and group

We will create a new user and group for this docker container called minecraft.

sudo useradd -r minecraft
sudo groupadd -r minecraft

Next we will add the new docker user to the default group (in this case, ubuntu).

sudo usermod -a -G minecraft ubuntu

Configuring yaml file for docker compose and deploy

For the sake of this guide we will be deploying a minecraft java edition server using the minecraft server image from itzg. They also have a bedrock image available, however, some of the server management commands will be different. You can create a new directory to put your compose file in, you can call it compose.yml, and it will contain something similar to the following (Iztg 2024a):

version: "3"

services:
  minecraft-server:
    image: itzg/minecraft-server
    restart: unless-stopped
    tty: true
    stdin_open: true
    environment:
      EULA: TRUE
      SERVER_NAME: "server-name"
    ports:
      - "25565:25565"
    volumes:
      - ./data:/data
    user: minecraft:minecraft

Deploy the docker container as a daemon.

docker compose up -d

Oracle Networking Firewall Rules

We want to add a firewall rule in our server’s subnet to port forward a TCP connection to our server. This will be the port specified in the compose file, in this case 25565.

On your Oracle Cloud admin page, you want to navigate to your server instance through the dashboard.

Inside of your instance, scroll down to resources and find Attached VNICs. Under the attached VNICs you should find an attached subnet, click on it to navigate to the subnet page.

In the subnet page you should find security lists. Click on the default security list that was created.

In the security list there are ingress rules. Add an ingress rule with source type CIDR, Source CIDR as 0.0.0.0/0 if you want to allow all ip addresses. Of course the IP protocol type will be TCP. Keep source port range empty and specify a destination port range as the ip address in our compose file, 25565. You may add an optional description such as Minecraft Server TCP connection.

Finally save all of your changes and your minecraft server to the world. All we need to do is test it.

Ping minecraft server

There are many websites that can check your minecraft server status and check it’s connection, such as mcsrvstat.us. You will need the IP address of the oracle instance, if you are in an ssh session on the server you can check the ip address using curl ipinfo.io, or you can see the ip address of the server through the main instances webpage under Instance access.

Whitelist users

Generally it is a good idea to enable a whitelist on your server if it is just private between friends so random users don’t join and grief your world.

Method 1: Using rcon

You can access the rcon-cli on the server side through docker exec (Iztg 2024b).

docker exec -it <name-of-server-container> rcon-cli

If you don’t know the name of your container, list existing containers using docker ps and find the container name that is using the itzg/minecraft-server docker image.

You should now be in a separate console that will start with >. Input the following command into the console to enable the server’s use of the whitelist (Minecraft Wiki 2024b).

whitelist on

To add users using the whitelist add command, the syntax is as follows (Minecraft Wiki 2024b).

whitelist add <targets>

See your whitelisted users (Minecraft Wiki 2024b).

whitelist list

You can add users as operators so they can execute server commands whilte in the game (Minecraft Wiki 2024a).

op <targets>

Method 2: Editing server.properties and whitelist.json

You will want to find the configuration files that exist in the /data volume that you specified in your compose configuration file.

First edit the server.properties file to enable the server white list.

white-list=true

Edit whitelist.json to add user names and UUIDs you wish to add. You can search for UUIDs for each username through minecraftuuid.com. The template should look as follows (Minecraft Wiki 2024c):

[
  {
    "uuid": "f430dbb6-5d9a-444e-b542-e47329b2c5a0",
    "name": "username"
  },
  {
    "uuid": "e5aa0f99-2727-4a11-981f-dded8b1cd032",
    "name": "username"
  }
]

Restart the server using the docker restart command.

docker restart <name-of-server-container>

References

Minecraft Wiki. 2024a. “Commands/Op - Minecraft Wiki.” https://minecraft.fandom.com/wiki/Commands/op.
———. 2024b. “Commands/Whitelist - Minecraft Wiki.” https://minecraft.fandom.com/wiki/Commands/whitelist.
———. 2024c. “Whitelist.Json - Minecraft Wiki.” https://minecraft.fandom.com/wiki/Whitelist.json.
The Lady from UN. 2021. “How to Claim a Legacy YouTube Account | 2021 - YouTube.” https://www.youtube.com/watch?v=WQejhyQZNr8&t=0s.
cevoj35548. 2022. “🚀 Free Lifetime 200GB VPS, 4x CPU Cores, 24GB Memory 🚀.” https://rentry.co/oraclevps.
iztg. 2024a. “Minecraft Server on Docker (Java Edition).” https://docker-minecraft-server.readthedocs.io/en/latest/#using-docker-compose.
———. 2024b. “Sending Commands - Minecraft Server on Docker (Java Edition).” https://docker-minecraft-server.readthedocs.io/en/latest/commands/.