Deploy a Minecraft Java Edition server using Docker for easy management, updates, and portability.
Create a directory to store your server configuration and world data.
mkdir minecraft-server
cd minecraft-serverCreate a docker-compose.yml file with your server configuration.
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: trueitzg/minecraft-server
This popular Docker image supports many server types including Paper, Spigot, Forge, and Fabric. See the documentation for all options.
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 downThe first startup will take a few minutes as it downloads the Minecraft server files and generates the world.
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"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 AllowPort Forwarding
If hosting from home, configure port forwarding on your router to forward port 25565 to your server's local IP address.
The itzg/minecraft-server image supports various server types. Modify the TYPE environment variable:
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "LATEST"
MEMORY: "4G"
# Paper offers better performance and plugin supportVANILLA
Official Mojang server
PAPER
High performance, plugins
FORGE
Mod support
FABRIC
Lightweight mods
Common Docker commands for server management:
docker compose pull && docker compose up -dcp -r ./data/world ./backups/docker stats minecraft-server