# Minecraft Server

> Minecraft Java Edition server with RCON support.

- Category: Media & Entertainment
- Difficulty: beginner
- Components: minecraft
- Tags: minecraft, game-server, java, gaming, multiplayer
- Source: https://docker.recipes/media/minecraft-server

## Overview

Minecraft Java Edition is the original version of Mojang's legendary sandbox game that revolutionized open-world creativity and multiplayer gaming. First released in 2009, Minecraft allows players to build, explore, and survive in procedurally generated worlds made of blocks, supporting both creative building and survival gameplay modes. The Java Edition remains the most feature-rich version with extensive modding support, regular updates, and the ability to run custom servers with various modifications and plugins.

This Docker stack combines the itzg/minecraft-server image with RCON (Remote Console) capabilities to create a fully-featured multiplayer Minecraft server environment. The itzg image is the most popular containerized Minecraft solution, supporting multiple server types including Vanilla, Paper, Forge, Fabric, and Quilt, while RCON provides remote administration capabilities for server management without requiring in-game access. The configuration enables persistent world storage, memory optimization, and flexible server type switching.

This setup is perfect for families wanting private servers, gaming communities requiring reliable uptime, and developers testing Minecraft mods or plugins. The combination of Docker containerization with the mature itzg image provides stability and easy updates, while RCON support enables automated server management and integration with external tools like Discord bots or web dashboards.

## Features

- Multi-server type support including Vanilla, Paper, Forge, Fabric, Quilt, and Modpack installations
- RCON protocol integration for remote server administration and command execution
- Automatic Java Edition version management with support for latest, specific, or snapshot builds
- Memory allocation optimization with configurable JVM heap size settings
- Operator permissions system with environment variable configuration for admin users
- Custom MOTD (Message of the Day) display for server branding and information
- Interactive TTY support for direct console access and real-time log monitoring
- Automatic EULA acceptance handling for legal compliance and server startup

## Use cases

- Private family Minecraft servers with whitelist protection and custom rules
- Gaming community hosting with modded content and plugin-based gameplay enhancements
- Educational institutions running Minecraft Education Edition alternatives for STEM learning
- Content creators and streamers hosting subscriber-only servers for community engagement
- Minecraft mod and plugin developers requiring test environments with quick reset capabilities
- Home lab enthusiasts running 24/7 servers for friends with automated backups and monitoring
- LAN party organizers needing portable server instances with custom maps and game modes

## Prerequisites

- Docker Engine 20.10+ and Docker Compose V2 for container orchestration support
- Minimum 3GB RAM available (2GB for Minecraft + 1GB for system overhead)
- Port 25565 available for Minecraft client connections and port 25575 for RCON access
- Valid Minecraft Java Edition account for each player connecting to the server
- Basic understanding of Minecraft server administration and player permission systems
- Sufficient disk space for world data storage (worlds can grow to several GB over time)

## docker-compose.yml

```yaml
services:
  minecraft:
    image: itzg/minecraft-server:latest
    container_name: minecraft
    restart: unless-stopped
    ports:
      - "${MC_PORT:-25565}:25565"
      - "${RCON_PORT:-25575}:25575"
    environment:
      - EULA=TRUE
      - TYPE=${SERVER_TYPE:-VANILLA}
      - VERSION=${MC_VERSION:-LATEST}
      - MEMORY=${MEMORY:-2G}
      - RCON_PASSWORD=${RCON_PASSWORD:-minecraft}
      - ENABLE_RCON=true
      - OPS=${OPS:-}
      - MOTD=${MOTD:-A Minecraft Server}
    volumes:
      - minecraft_data:/data
    networks:
      - minecraft-network
    tty: true
    stdin_open: true

volumes:
  minecraft_data:

networks:
  minecraft-network:
    driver: bridge
```

## .env

```bash
# Minecraft Server
MC_PORT=25565
RCON_PORT=25575
SERVER_TYPE=VANILLA
MC_VERSION=LATEST
MEMORY=2G
RCON_PASSWORD=minecraft
OPS=
MOTD=A Minecraft Server
```

## Usage notes

- Server at localhost:25565
- RCON at localhost:25575
- Set OPS for admin players
- Supports Paper, Forge, Fabric, etc.

## Troubleshooting

- OutOfMemoryError in logs: Increase MEMORY environment variable value or reduce server view distance and entity limits
- RCON connection refused errors: Verify RCON_PORT is properly forwarded and RCON_PASSWORD matches client configuration
- Players cannot connect to server: Check firewall rules allow port 25565 and verify MC_PORT environment variable matches client settings
- Server stuck on 'Loading libraries' message: Insufficient memory allocation, increase MEMORY value to at least 2G for modded servers
- World corruption after container restart: Ensure proper shutdown using RCON 'stop' command rather than killing container process
- Mod loading failures with Forge/Fabric: Verify VERSION environment variable matches mod compatibility requirements and all dependencies are present

