Tools
compose.yaml for a Minecraft server in Docker
Pick the server software, version and memory to get a compose.yaml for the popular itzg/minecraft-server image: it downloads Paper, Leaf or Purpur itself, accepts the EULA and sets server options from environment variables. The image tag matches the Java the version requires.
docker-compose
An image with Java 25 — what this version requires.
Inside the container the server listens on 25565; this is the port players connect to.
Comma-separated names. A whitelist also turns on white-list in server.properties.
compose.yaml
services:
mc:
image: itzg/minecraft-server:java25
tty: true
stdin_open: true
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "26.3"
MEMORY: "6G"
USE_AIKAR_FLAGS: "true"
ONLINE_MODE: "true"
DIFFICULTY: "normal"
MODE: "survival"
MAX_PLAYERS: "50"
STOP_DURATION: "120"
volumes:
- ./data:/data
stop_grace_period: 2m
restart: unless-stoppeddocker compose up -d
docker compose logs -f mcA Minecraft server in Docker
The itzg/minecraft-server image downloads the server software from the TYPE variable (PAPER, LEAF, PURPUR) and VERSION, and takes server.properties settings from variables like DIFFICULTY, MAX_PLAYERS and ONLINE_MODE. EULA: "TRUE" accepts the Minecraft licence; without it the server won't start.
Java comes from the image tag: java25 for 26.x and java21 for 1.20–1.21.11, following PaperMC's table. MEMORY sets Xms and Xmx together. Everything the server creates — the world, configs, plugins — lives in ./data on the machine and survives recreating the container.
STOP_DURATION and stop_grace_period give the server time to save the world on shutdown. Send the server commands with docker compose exec mc rcon-cli <command>: RCON is on by default in the image — more in our Docker article.
Plugins go in ./data/plugins, just like on a regular server. DGuard, the best anticheat for a modern Minecraft server, runs on Paper and Leaf 1.21–26.3 — in Docker too.
Read in the knowledge base
FAQ
How do I run a Minecraft server in Docker?
Save the generator's compose.yaml in an empty folder and run docker compose up -d. Follow the log with docker compose logs -f mc; the server is ready when a Done line appears.
Which itzg image tag should I use?
The one with the Java you need: java25 for 26.x, java21 for 1.20–1.21.11. The generator picks it from the version you choose.
Where are the world and plugins?
In the ./data folder next to compose.yaml. Plugins go in ./data/plugins; restart the container after adding them.
Can I run Leaf in Docker?
Yes: in the itzg/minecraft-server image it's TYPE: "LEAF".
The tools are free. So is anti-cheat protection
DGuard — the best anticheat for a modern Minecraft server — catches all 47 cheat types in our comparison; the nearest rival, Intave, catches 27. Free up to 30 players online, with the same protection as on paid plans.