Simple way to host a Minecraft server using Docker. No complex setup needed.
What you need: Docker installed on your computer/server
Time needed: 5 minutes
Cost: Free (if hosting locally)
Create a file called docker-compose.yml:
services:
mc:
image: itzg/minecraft-server:latest
container_name: minecraft-server
restart: unless-stopped
tty: true
stdin_open: true
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: "VANILLA"
VERSION: "1.21.4"
MEMORY: "2G"
SERVER_NAME: "My Minecraft Server"
MOTD: "Welcome to my server!"
DIFFICULTY: "normal"
MODE: "survival"
MAX_PLAYERS: "20"
ONLINE_MODE: "true"
ALLOW_NETHER: "true"
ANNOUNCE_PLAYER_ACHIEVEMENTS: "true"
ENABLE_COMMAND_BLOCK: "false"
FORCE_GAMEMODE: "false"
GENERATE_STRUCTURES: "true"
HARDCORE: "false"
MAX_BUILD_HEIGHT: "320"
MAX_WORLD_SIZE: "29999984"
PVP: "true"
SPAWN_ANIMALS: "true"
SPAWN_MONSTERS: "true"
SPAWN_NPCS: "true"
VIEW_DISTANCE: "10"
SEED: ""
# Optional: Enable backups
# ENABLE_AUTOPAUSE: "true"
# AUTOPAUSE_TIMEOUT_EST: "3600"
volumes:
- ./data:/data
# Optional: Resource limits
deploy:
resources:
limits:
memory: 3G
reservations:
memory: 2G
Start server: docker compose up -d
Stop server: docker compose down
View logs: docker compose logs -f
Update server: docker compose pull && docker compose up -d
VERSION: Minecraft version (1.21.4, 1.20.1, etc.)
MEMORY: RAM allocation (2G recommended minimum)
TYPE: Server type (VANILLA, PAPER, FABRIC, FORGE)
ONLINE_MODE: true = require official Minecraft accounts
MAX_PLAYERS: Maximum concurrent players
DIFFICULTY: peaceful, easy, normal, hard
MODE: survival, creative, adventure, spectator
VIEW_DISTANCE: How far players can see (affects performance)
Low-end (1-4 players): MEMORY: "1G", VIEW_DISTANCE: "6"
Medium (5-10 players): MEMORY: "2G", VIEW_DISTANCE: "8"
High-end (10+ players): MEMORY: "4G", VIEW_DISTANCE: "10"
Resource limits: Prevents server from using too much RAM
Cracked server: Set ONLINE_MODE: "false"
Peaceful mode: Set DIFFICULTY: "peaceful"
Creative server: Set MODE: "creative"
PvP disabled: Set PVP: "false"
Custom world: Add SEED: "your-seed-here"
Auto-pause: Uncomment ENABLE_AUTOPAUSE lines
Local: Connect to localhost:25565
Remote: Connect to your-server-ip:25565
Notes: Open port 25565 in firewall if hosting remotely
World data: Stored in ./data folder
Backup: Just copy the data folder
Notes: Data persists even if container is deleted
Port already in use: Change "25565:25565" to "25566:25565"
Out of memory: Increase MEMORY value and resource limits
Can't connect: Check firewall and port forwarding
Server won't start: Check logs with docker compose logs
Players can't join: Verify ONLINE_MODE setting matches client type
Lag issues: Reduce VIEW_DISTANCE or increase MEMORY
Home computer: Free, but limited uptime
VPS (DigitalOcean, etc.): $5-20/month, always online
Raspberry Pi: Cheap, low power, good for small groups