1. Install Docker
Follow How to run Docker and Docker Compose on a VPS, including the log size limit, then come back here.
2. Write the Compose File
mkdir -p ~/minecraft && cd ~/minecraft nano compose.yaml
services:
mc:
image: itzg/minecraft-server
container_name: minecraft
ports:
- "25565:25565"
environment:
EULA: "TRUE" # you accept Minecraft's EULA
TYPE: "VANILLA" # or PAPER, FABRIC, FORGE
VERSION: "LATEST"
MEMORY: "4G"
DIFFICULTY: "normal"
MOTD: "Our server"
WHITELIST: "yourname,friend1,friend2"
ENFORCE_WHITELIST: "TRUE"
OPS: "yourname"
volumes:
- ./data:/data
restart: unless-stopped
tty: true
stdin_open: trueThe whitelist keeps strangers out: a public server on a known address gets found by scanners. Setting EULA to TRUE means you accept the Minecraft End User License Agreement.
3. Start It and Open the Port
docker compose up -d docker compose logs -f # wait for "Done", then Ctrl+C
If you turned on the firewall on your server's page in the dashboard, add a rule for TCP 25565 there. Players connect to 203.0.113.10 (your server's address), or to a domain name you point at it.
4. Use the Server Console
docker exec -i minecraft rcon-cli > whitelist add newplayer > op yourname > list
Settings in the compose file are applied when the container starts. Change one, then run docker compose up -d again.
5. Back Up the World
Everything lives in ~/minecraft/data. Pause saving while you copy it, so the world is not half-written:
docker exec minecraft rcon-cli save-off docker exec minecraft rcon-cli save-all flush tar -czf ~/mc-backup-$(date +%F).tar.gz -C ~/minecraft data docker exec minecraft rcon-cli save-on
Copy the archive off the server, or back up the whole folder nightly with Borg and a storage box.
6. Update
cd ~/minecraft docker compose pull && docker compose up -d
With VERSION: "LATEST" the server moves to each new Minecraft release on restart. Pin a version, such as the one your mods support, to stay on it, and back up before any upgrade.