Minecraft
This example runs a Minecraft Java server on Unikraft Cloud with:
- A reusable base image (
minecraft:latest) built from itzg/minecraft-server (Java 25) - Configuration overrides through auxiliary ROMs (optional)
- Template-based startup for faster instance creation
- TLS-exposed Minecraft and SSH endpoints
Prerequisites
-
Install the unikraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.
-
Clone the
examplesrepository andcdinto theexamples/minecraft/directory:Code -
Review and adjust the base server settings in
base/.env. You can check out this documentation for available configuration options. Make sure to also set yourPUBKEYfor SSH access, and optionally setTEMPLATE_WITH_WORLDif you want the template to include the world (see below). Optionally, create per-config overrides in<config>/.env(for examplebingo/.env). All the.envfiles are packaged as auxiliary ROMs and mounted at/rom/<config>.
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
unikraft
Deployment Workflow
Package the base image
First, package and push the base Minecraft server image:
unikraft
The image is built from the Docker image itzg/minecraft-server and includes a few tweaks:
- The entrypoint is wrapped around a custom
wrapper.shscript that:- Starts an SSH server
- Loads the environment configuration from the attached ROM(s)
- Disables scale-to-zero before executing the original entrypoint
- The server configuration scripts from the original image are patched (see patches/) to trigger the template snapshot before the full warm-up of the server, which allows faster instance creation from the template. Scale-to-zero is enabled after server initialization.
Create an instance template from the base image
This step is required to enable fast startups from the base image, which is particularly important for a Minecraft server given the long initialization time.
If you only customized the server using the base .env file, create the instance with one ROM:
unikraft
The output shows the instance details:
unikraft
If you also have per-config overrides (for example in bingo/.env), create the instance with multiple ROMs:
unikraft
The instance will run until initialization is complete, then it will be snapshotted as a template and immediately deleted.
The exact moment of snapshotting can be configured in patches/start-finalExec, but it can also be configured by the following environment variable:
- If
TEMPLATE_WITH_WORLD=true, then the snapshot will be triggered after world generation - Otherwise, the snapshot will be triggered after extracting the jar files and writing configuration files, before world generation
You can follow the logs of the instance to check the progress:
unikraft
Once they stop, the template is ready and you can check it with:
Create an instance from the template
You can now create new instances from the template, which will boot much faster than the original base image:
unikraft
The output shows the instance address and other details:
unikraft
In this case, the instance name is minecraft and the address is https://hidden-water-ewr8l9sp.fra.unikraft.app.
A sample log output of the server getting ready:
unikraft
Code
Connect to Minecraft and SSH
At the moment, Unikraft Cloud can only expose these services over TLS.
Since Minecraft clients and SSH clients do not support TLS, you can use socat to terminate TLS locally and expose plain TCP endpoints for your clients to connect to.
Minecraft proxy
Code
Then connect your Minecraft client to localhost:25565.
SSH proxy
Code
Then connect your SSH client to localhost:2222 with the username root and the SSH key you configured in the .env file.
Administration
RCON
SSH into the instance (via the local TLS proxy), then run:
Code
You can then execute any Minecraft server command through the RCON interface, for example:
Code
You can also give yourself operator permissions to execute these commands in-game:
Code
Whitelist in offline mode
Offline mode does not produce online UUIDs.
If you whitelist players manually, compute UUIDs per username and update /data/whitelist.json.
Code
Format:
Code
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
unikraft
Or visit the CLI Reference.