Back to Setup Guides
    Docker

    Minecraft Server Setup with Docker

    Deploy a Minecraft Java Edition server using Docker for easy management, updates, and portability.

    Prerequisites

    • Docker installed on your system
    • Docker Compose (included with Docker Desktop)
    • At least 2GB RAM available for the container

    1Create Project Directory

    Create a directory to store your server configuration and world data.

    mkdir minecraft-server
    cd minecraft-server

    2Create Docker Compose File

    Create a docker-compose.yml file with your server configuration.

    docker-compose.yml
    version: "3.8"
    
    services:
      minecraft:
        image: itzg/minecraft-server:latest
        container_name: minecraft-server
        restart: unless-stopped
        ports:
          - "25565:25565"
        environment:
          EULA: "TRUE"
          TYPE: "VANILLA"
          VERSION: "LATEST"
          MEMORY: "4G"
          MAX_PLAYERS: "20"
          MOTD: "My Minecraft Server"
          DIFFICULTY: "normal"
          MODE: "survival"
          PVP: "true"
          ONLINE_MODE: "true"
          VIEW_DISTANCE: "10"
          SPAWN_PROTECTION: "16"
        volumes:
          - ./data:/data
        tty: true
        stdin_open: true

    itzg/minecraft-server

    This popular Docker image supports many server types including Paper, Spigot, Forge, and Fabric. See the documentation for all options.

    3Start the Server

    Start your Minecraft server using Docker Compose.

    # Start the server in detached mode
    docker compose up -d
    
    # View logs
    docker compose logs -f
    
    # Stop the server
    docker compose down

    The first startup will take a few minutes as it downloads the Minecraft server files and generates the world.

    4Server Console Access

    Access the server console to run commands.

    # Attach to the container console
    docker attach minecraft-server
    
    # To detach without stopping: Ctrl+P, Ctrl+Q
    
    # Or run commands directly
    docker exec minecraft-server rcon-cli "say Hello World"

    5Configure Firewall

    Ensure port 25565 is open in your firewall.

    # Linux (UFW)
    sudo ufw allow 25565/tcp
    
    # Windows PowerShell (as Administrator)
    New-NetFirewallRule -DisplayName "Minecraft Server" -Direction Inbound -Protocol TCP -LocalPort 25565 -Action Allow

    Port Forwarding

    If hosting from home, configure port forwarding on your router to forward port 25565 to your server's local IP address.

    6(Optional) Alternative Server Types

    The itzg/minecraft-server image supports various server types. Modify the TYPE environment variable:

    docker-compose.yml (Paper example)
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      VERSION: "LATEST"
      MEMORY: "4G"
      # Paper offers better performance and plugin support

    VANILLA

    Official Mojang server

    PAPER

    High performance, plugins

    FORGE

    Mod support

    FABRIC

    Lightweight mods

    Managing Your Server

    Common Docker commands for server management:

    • Update server: docker compose pull && docker compose up -d
    • Backup world: cp -r ./data/world ./backups/
    • View resource usage: docker stats minecraft-server