Skip to main content

Run your first server

Get a basic Minecraft server running in under 5 minutes using Docker run commands.
1

Accept the Minecraft EULA

Before running any server, you must accept the Minecraft EULA by including -e EULA=TRUE in all commands.
The server will not start without EULA=TRUE set. This is a requirement from Mojang/Microsoft.
2

Run the basic server

Execute this command to start a server with the latest Minecraft version:
docker run -d -it -p 25565:25565 -e EULA=TRUE itzg/minecraft-server
This command:
  • Downloads and runs the latest vanilla Minecraft server
  • Exposes port 25565 for player connections
  • Runs in detached mode (-d)
  • Enables interactive terminal (-it) for console access
3

Connect to your server

Open Minecraft, go to Multiplayer, and connect to:
  • localhost:25565 (if playing on the same machine)
  • your-ip-address:25565 (if connecting from another machine)
The server data is stored in an anonymous Docker volume. To persist your world and configuration, see the persistent data section below.

Persistent data

The Minecraft server stores all its data in the container’s /data directory. To keep your world and configuration when the container is removed, mount a volume or directory.

Using a host directory

Mount a directory from your host machine to persist the server data:
docker run -d -it -p 25565:25565 \
  -e EULA=TRUE \
  -v /path/on/host:/data \
  itzg/minecraft-server
Replace /path/on/host with the actual path where you want to store the server data, such as:
  • Linux/Mac: /home/user/minecraft-data
  • Windows: C:\Users\username\minecraft-data
For rootless containers (Podman) or systems using SELinux/AppArmor, append :Z to the volume mapping:
-v /path/on/host:/data:Z

Using a named volume

Create and use a named Docker volume:
# Create a named volume
docker volume create minecraft-data

# Run the server with the named volume
docker run -d -it -p 25565:25565 \
  -e EULA=TRUE \
  -v minecraft-data:/data \
  itzg/minecraft-server

Common configurations

Specific Minecraft version

Run a specific version instead of the latest:
docker run -d -it -p 25565:25565 \
  -e EULA=TRUE \
  -e VERSION=LATEST \
  itzg/minecraft-server

Different server types

Run Paper, Spigot, Forge, or other server types:
docker run -d -it -p 25565:25565 \
  -e EULA=TRUE \
  -e TYPE=PAPER \
  itzg/minecraft-server

Server properties

Configure server settings using environment variables:
docker run -d -it -p 25565:25565 \
  -e EULA=TRUE \
  -e MEMORY=4G \
  -e MAX_PLAYERS=100 \
  -e VIEW_DISTANCE=15 \
  -e LEVEL_TYPE=LARGEBIOMES \
  -e MOTD="Welcome to my server!" \
  -e DIFFICULTY=hard \
  -e MODE=survival \
  -v minecraft-data:/data \
  itzg/minecraft-server
All standard server.properties entries can be set via environment variables. The variable names match the property names in uppercase.

Managing your server

View server logs

Follow the server console output:
docker logs -f <container-name-or-id>

Stop the server

Gracefully stop the server:
docker stop <container-name-or-id>

Start the server

Start a stopped container:
docker start <container-name-or-id>

Access server console

Attach to the server console for commands:
docker attach <container-name-or-id>
Press Ctrl+P, Ctrl+Q to detach without stopping the server.

Restart for updates

When using VERSION=LATEST or VERSION=SNAPSHOT, simply restart the container to upgrade:
docker restart <container-name-or-id>

Common environment variables

Here are the most commonly used environment variables:
VariableDefaultDescription
EULA-Must be set to TRUE to accept the Minecraft EULA
VERSIONLATESTMinecraft version: LATEST, SNAPSHOT, or specific version like 1.20.4
TYPEVANILLAServer type: VANILLA, PAPER, SPIGOT, FORGE, FABRIC, etc.
MEMORY1GJVM memory allocation, e.g., 2G, 4G, 8G
MAX_PLAYERS20Maximum number of players
VIEW_DISTANCE10Server view distance in chunks
DIFFICULTYeasyGame difficulty: peaceful, easy, normal, hard
MODEsurvivalGame mode: survival, creative, adventure, spectator
MOTDAuto-generatedServer message of the day
LEVEL_TYPEDEFAULTWorld type: DEFAULT, FLAT, LARGEBIOMES, AMPLIFIED
SEED-World generation seed
PVPtrueEnable player vs player combat
ALLOW_NETHERtrueEnable the Nether dimension
For a complete list of available environment variables and server types, see the full documentation.

Example: Complete server setup

Here’s a complete example with common settings:
docker run -d \
  --name minecraft \
  -p 25565:25565 \
  -e EULA=TRUE \
  -e TYPE=PAPER \
  -e VERSION=1.20.4 \
  -e MEMORY=4G \
  -e MAX_PLAYERS=50 \
  -e VIEW_DISTANCE=12 \
  -e DIFFICULTY=normal \
  -e MODE=survival \
  -e MOTD="My Awesome Minecraft Server" \
  -e ENABLE_COMMAND_BLOCK=true \
  -e SPAWN_PROTECTION=0 \
  -v ~/minecraft-data:/data \
  --restart unless-stopped \
  -it \
  itzg/minecraft-server
This configuration:
  • Runs a Paper server on Minecraft 1.20.4
  • Allocates 4GB of RAM
  • Supports up to 50 players
  • Persists data to ~/minecraft-data
  • Automatically restarts unless manually stopped
  • Uses normal difficulty and survival mode

Next steps

Docker Compose setup

Learn how to use Docker Compose for easier management

Full documentation

Explore advanced features like mods, plugins, and backups
Remember to regularly backup your /data directory to prevent world data loss. Consider using automated backup solutions or volume snapshots.

Build docs developers (and LLMs) love