WikiJS/home/homelab/Setup-Minecraft-Forge-Server.md

192 lines
7.8 KiB
Markdown

---
title: Setting up a Forge Minecraft Server
description:
published: true
date: 2025-10-30T15:47:19.555Z
tags:
editor: markdown
dateCreated: 2025-10-30T15:47:19.555Z
---
# Setting Up a Forge Minecraft Server on a Proxmox Ubuntu Container with Docker
This guide provides step-by-step instructions for deploying a Forge Minecraft server using Docker on an Ubuntu container in Proxmox. It assumes you have already updated your Ubuntu container (`sudo apt update && sudo apt upgrade -y`) and installed Docker (`sudo apt install docker.io docker-compose -y`). We'll use the popular `itzg/minecraft-server` Docker image, which supports Forge modding out of the box.
**Note:** This setup runs the server in a Docker container inside your Proxmox LXC container. Ensure your Proxmox host has sufficient resources (at least 4GB RAM allocated to the LXC container for a basic server). You'll also need to configure port forwarding in Proxmox for external access (e.g., forward host port 25565 to container port 25565).
## Prerequisites
- Ubuntu (20.04 or later) LXC container in Proxmox with Docker and Docker Compose installed.
- Root or sudo access in the container.
- Basic familiarity with terminal commands.
- Minecraft Java Edition client (version matching your server) for testing.
- Optional: A specific Minecraft version (e.g., 1.20.1) and Forge version for compatibility with your mods.
## Step 1: Create a Working Directory
SSH into your Ubuntu container and create a dedicated directory for the server files. This keeps things organized and allows easy backups.
```bash
mkdir ~/minecraft-forge-server
cd ~/minecraft-forge-server
```
Create subdirectories for data persistence and mods:
```bash
mkdir data mods backups
```
- `data`: Stores server files (worlds, configs).
- `mods`: Place your Forge-compatible .jar mod files here (they auto-copy to the server).
- `backups`: Optional directory for automated backups (covered later).
## Step 2: Configure Docker Compose
Create a `docker-compose.yml` file in the working directory. This defines the server configuration using environment variables for Forge.
Use a text editor like `nano`:
```bash
nano docker-compose.yml
```
Paste the following content (customize `VERSION`, `FORGE_VERSION`, `MEMORY`, etc., as needed):
```yaml
version: "3.8"
services:
minecraft:
image: itzg/minecraft-server:latest # Uses the latest image
container_name: forge-minecraft-server
ports:
- "25565:25565/tcp" # Minecraft server port (expose to Proxmox host)
- "25575:25575/tcp" # RCON port (optional, for remote console access)
environment:
# Core settings
EULA: "TRUE" # Required: Accept Minecraft EULA
TYPE: "FORGE" # Sets server type to Forge
VERSION: "1.20.1" # Minecraft version (check compatibility with your mods)
FORGE_VERSION: "latest" # Or specify e.g., "47.2.0" for a exact version
# Performance and gameplay
MEMORY: "4G" # Allocate RAM (adjust based on your setup/mods)
DIFFICULTY: "normal" # easy, normal, hard, peaceful
MODE: "survival" # survival, creative, adventure, spectator
MAX_PLAYERS: 10 # Adjust as needed
# Optional: RCON for remote management
ENABLE_RCON: "true"
RCON_PASSWORD: "your_secure_rcon_password" # Change this!
RCON_PORT: 25575
# Optional: Backup settings (runs daily at 5 AM)
ENABLE_AUTOMATION: "true"
BACKUP_INTERVAL: "1d"
BACKUP_HOUR: "5"
# Debug mode for troubleshooting
DEBUG: "false"
volumes:
- ./data:/data # Persist server data
- ./mods:/mods:ro # Read-only mods directory (auto-copies to /data/mods)
- ./backups:/backups # Backup destination
restart: unless-stopped # Auto-restart on failure
stdin_open: true
tty: true
healthcheck:
test: ["CMD-SHELL", "mc-health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
```
Save and exit (`Ctrl+O`, `Enter`, `Ctrl+X` in nano).
**Key Environment Variables Explained:**
- `TYPE: "FORGE"`: Installs Forge mod loader.
- `VERSION`: Specifies the Minecraft version (e.g., "1.20.1"). Use "LATEST" for the newest stable.
- `FORGE_VERSION`: Defaults to recommended; set to "latest" or a specific version like "47.2.0".
- `MEMORY`: RAM allocation (e.g., "6G" for mod-heavy servers).
- For full options, refer to the [image documentation](https://github.com/itzg/docker-minecraft-server).
## Step 3: Start the Server
From the working directory, pull the image and start the container:
```bash
docker compose up -d
```
- `-d` runs in detached mode (background).
- The first run downloads Forge and Minecraft files (may take 5-10 minutes).
Monitor logs:
```bash
docker compose logs -f
```
Look for "Done" messages indicating the server is ready. Press `Ctrl+C` to stop tailing logs.
**Proxmox Networking Note:** In Proxmox, ensure the LXC container's network is bridged (vmbr0) and forward port 25565 from the Proxmox host to the container's IP (e.g., via iptables: `sudo iptables -t nat -A PREROUTING -p tcp --dport 25565 -j DNAT --to-destination <container_ip>:25565`).
## Step 4: Configure Server Properties
After startup, edit `data/server.properties` for fine-tuning (e.g., world name, spawn protection).
Stop the server temporarily:
```bash
docker compose stop
```
Edit the file:
```bash
nano data/server.properties
```
Common edits:
- `server-port=25565`
- `motd=Your Forge Server!`
- `online-mode=true` (set to false for cracked clients, but not recommended)
- `pvp=true`
- `difficulty=normal`
Restart:
```bash
docker compose start
```
For RCON access (remote console), use tools like mcrcon: `mcrcon -H <container_ip> -P 25575 -p your_secure_rcon_password "say Hello from RCON!"`.
## Step 5: Adding Mods
1. Download Forge-compatible mods from [CurseForge](https://www.curseforge.com/minecraft/mc-mods) (match your Minecraft/Forge version).
2. Place .jar files in the `mods` directory on the host.
3. Restart the server (`docker compose restart`).
4. Mods auto-copy to `/data/mods` inside the container.
**Client-Side Note:** Players must install the same mods on their Minecraft client via a Forge launcher (e.g., CurseForge app).
For modpacks, use `FORGE_INSTALLER_URL` in the environment to point to a custom installer, or manually add mods post-setup.
## Step 6: Backups and Maintenance
- **Automated Backups:** Enabled in the compose file; backups save to `./backups`.
- **Manual Backup:** `docker compose exec minecraft rsync -a /data/ /backups/manual-$(date +%Y%m%d)/`
- **Update Server:** Edit `VERSION` or `FORGE_VERSION`, then `docker compose down && docker compose up -d`.
- **Stop Server:** `docker compose down`
- **Remove Container (for clean reinstall):** `docker compose down -v` (deletes volumes—backup first!).
## Troubleshooting
- **Port Conflicts:** Check if 25565 is in use: `sudo netstat -tuln | grep 25565`. Change ports in compose if needed.
- **Out of Memory:** Increase `MEMORY` or allocate more RAM to the LXC container in Proxmox.
- **Download Failures:** Ensure Docker has internet access; retry with `docker compose pull`.
- **Mod Incompatibilities:** Verify versions match; check logs for errors.
- **Firewall:** In Ubuntu, allow ports: `sudo ufw allow 25565/tcp`.
- **Logs Full of Errors:** Set `DEBUG: "true"` temporarily and check `docker compose logs`.
For advanced setups (e.g., multiple servers, proxies), see the [full examples](https://github.com/itzg/docker-minecraft-server/tree/master/examples).
## Security Considerations
- Use a strong `RCON_PASSWORD`.
- Enable `online-mode=true` to prevent unauthorized access.
- Regularly update the image and mods.
- Expose only necessary ports and use Proxmox firewall rules.
Your Forge server should now be running! Connect from Minecraft using your Proxmox host's IP:25565. Happy modding!
*Last Updated: October 30, 2025*
*Sources: itzg/docker-minecraft-server GitHub, community guides.*