Run a Minecraft Server in Docker (Complete 2026 Guide)

Published on

Docker makes Minecraft server management easier with containers. Here is how to set up Minecraft in Docker with docker-compose, including Forge and Fabric support.

Written by Jochem – Infrastructure Expert – 5-10 years experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

Run a Minecraft Server in Docker (Complete 2026 Guide)

Docker Minecraft server setup

Docker containers make server management cleaner. Your Minecraft server runs in an isolated environment with its own Java version, dependencies, and configuration. Updates, backups, and multiple servers become simpler.

Why Docker for Minecraft?

  • Isolation: Each server runs in its own container. No Java version conflicts.
  • Reproducibility: Your server setup is defined in a file. Deploy the same configuration anywhere.
  • Easy updates: Pull a new image to update. Roll back by switching to a previous image.
  • Multiple servers: Run several Minecraft servers on one machine without conflicts.
  • Backups: Volume mounts make backup straightforward.

Prerequisites

Install Docker and Docker Compose on your server:

# Ubuntu / Debian
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

# Install Docker Compose plugin
apt install docker-compose-plugin

Quick Start with docker-compose

The most popular Minecraft Docker image is itzg/minecraft-server. It supports every server type: Vanilla, Paper, Purpur, Forge, Fabric, and more.

Create a docker-compose.yml file:

services:
  minecraft:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      VERSION: "1.21.1"
      MEMORY: "4G"
      VIEW_DISTANCE: 10
      MAX_PLAYERS: 20
      MOTD: "My Docker Minecraft Server"
    volumes:
      - ./data:/data
    restart: unless-stopped
    tty: true
    stdin_open: true

Start it:

docker compose up -d

Your server is running. World data persists in the ./data folder.

Server Types

Change the TYPE environment variable:

| TYPE | Server Software | |------|----------------| | VANILLA | Official Minecraft server | | PAPER | Paper (recommended for plugins) | | PURPUR | Purpur (Paper fork with more features) | | FABRIC | Fabric mod loader | | FORGE | Forge mod loader | | NEOFORGE | NeoForge (modern Forge fork) | | SPIGOT | Spigot |

Running a Forge Modpack

For a Forge modpack like ATM10:

services:
  minecraft:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "FORGE"
      VERSION: "1.20.1"
      MEMORY: "10G"
      FORGE_VERSION: "47.2.0"
    volumes:
      - ./data:/data
    restart: unless-stopped

Place your modpack's mods/ folder contents into ./data/mods/.

Running Fabric with Mods

services:
  minecraft:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "FABRIC"
      VERSION: "1.21.1"
      MEMORY: "4G"
    volumes:
      - ./data:/data
    restart: unless-stopped

Place Fabric mods (.jar files) in ./data/mods/.

Adding Plugins (Paper/Purpur)

Place plugin jars in ./data/plugins/. The container mounts the ./data volume, so you have full file access.

You can also auto-download plugins using environment variables:

environment:
  SPIGET_RESOURCES: "28140,81534"  # Plugin IDs from SpigotMC

Multiple Servers

Run multiple servers on different ports:

services:
  survival:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      MEMORY: "4G"
    volumes:
      - ./survival:/data

  creative:
    image: itzg/minecraft-server
    ports:
      - "25566:25565"
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      MEMORY: "2G"
      GAMEMODE: "creative"
    volumes:
      - ./creative:/data

JVM Arguments

Pass Aikar's flags through the JVM_XX_OPTS variable:

environment:
  JVM_XX_OPTS: "-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1"

Backups

Back up the entire ./data directory:

tar -czf backup-$(date +%Y%m%d).tar.gz ./data

For automated backups, add the backup container:

  backups:
    image: itzg/mc-backup
    environment:
      BACKUP_INTERVAL: "2h"
      RCON_HOST: minecraft
    volumes:
      - ./data:/data:ro
      - ./backups:/backups
    depends_on:
      - minecraft

Useful Commands

# View logs
docker compose logs -f minecraft

# Access server console
docker compose exec minecraft rcon-cli

# Stop server
docker compose stop

# Update to latest image
docker compose pull && docker compose up -d

# Restart server
docker compose restart minecraft

Docker vs Bare Metal

Docker adds minimal overhead. CPU performance is nearly identical to bare metal. Memory overhead is about 100 to 200 MB. For most servers, the management benefits outweigh the tiny performance cost.

Hosting Docker Minecraft

If you run Docker on a VPS, you need enough RAM for both Docker overhead and the Minecraft server. Space-Node VPS plans give you root access with KVM virtualization. Install Docker and run as many containers as your plan supports.


Get a VPS for your Docker setup. View VPS Hosting Plans

Jochem

About the Author

Jochem – Infrastructure Expert – Expert in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 5-10 years experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

I specialize in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters.

View my full bio and credentials →

Start Your MC Server Now Today

Join content creators worldwide who trust our Minecraft infrastructure. Setup is instant and support is always available. Start from €0.90/mo (Dirt) or €2.70/mo (Coal) and go live in minutes.

Run a Minecraft Server in Docker (Complete 2026 Guide)