aboutsummaryrefslogtreecommitdiffstats

Minecraft Multi-Server Docker Setup

Overview

This setup allows you to run one or more vanilla Minecraft servers on a single VPS using Docker Compose. Features include:

  • Fully .env-driven configuration.
  • Automated backups with timestamped filenames and retention.
  • Server-specific logs.
  • Resource limits (CPU/memory) per server.
  • Security hardening: non-root execution, read-only root filesystem, dropped capabilities.
  • Internal-only RCON.
  • Multi-server friendly.

Folder Structure

/opt/docker/minecraft/
├─ server1/
│  ├─ docker-compose.yml
│  └─ .env
├─ server2/
│  ├─ docker-compose.yml
│  └─ .env
└─ shared/
   └─ (optional shared resources)

.env Configuration Example

# Server identity
SERVER_NAME=server1
MC_IMAGE=itzg/minecraft-server
BACKUP_IMAGE=alpine:latest

# Ports
SERVER_PORT=25565
MC_INTERNAL_PORT=25565
RCON_PORT=25575

# Paths
DATA_PATH=/opt/docker/minecraft/server1/data
BACKUP_PATH=/opt/docker/minecraft/server1/backups
TMPFS_PATH=/tmp

# Minecraft settings
MC_VERSION=latest
MC_MEMORY=2G
MC_EULA=TRUE
ENABLE_RCON=true
RCON_PASSWORD=StrongPasswordHere
MC_UID=1000
MC_GID=1000

# Backup settings
BACKUP_INTERVAL=86400
MAX_BACKUPS=3
BACKUP_LOG_PREFIX=server1

# Security options
READ_ONLY=true
CAP_DROP=ALL
CAP_ADD=CHOWN,SETUID,SETGID
SECURITY_OPT=no-new-privileges:true

# Resource limits
MC_CPUS=1.5
MC_MAX_MEMORY=3G

# Logging
LOG_DRIVER=json-file
LOG_MAX_SIZE=10m
LOG_MAX_FILE=5
BACKUP_LOG_DRIVER=json-file
BACKUP_LOG_MAX_SIZE=5m
BACKUP_LOG_MAX_FILE=3

# Network
NETWORK_NAME=mc_net
NETWORK_DRIVER=bridge

Backup Logging Example

[server1] Backup completed: /backups/server1_20251030_153045.tar.gz
[server2] Backup completed: /backups/server2_20251030_153046.tar.gz

Running Multiple Servers

cd /opt/docker/minecraft/sv1
docker compose up -d

cd /opt/docker/minecraft/sv2
docker compose up -d

References