
The short answer: run a Minecraft Java Edition server in Docker with the itzg/minecraft-server image. Set EULA=TRUE, publish TCP port 25565, and mount a volume on /data so the world survives the container. The image downloads the server software, picks the right Java version and writes server.properties from environment variables. The quickest possible test is one command:
docker run -d -it --name mc -p 25565:25565 -e EULA=TRUE -v mc-data:/data itzg/minecraft-server
For anything you plan to keep, use the Docker Compose file in the image above. The rest of this guide covers it line by line, then the jobs that come after: the console, whitelists, mods and plugins, backups, updates, Bedrock, and the errors people actually hit. Every variable and command here has been checked against the image’s official documentation as of 31 October 2026 (image release 2026.10.1, Minecraft Java 26.3).
Why Docker Is the Right Way to Run Minecraft
A bare-metal Minecraft server means installing the right Java on the host, downloading the correct server JAR, writing a systemd unit and remembering where everything lives. Docker removes each of those jobs.
Updating to a new Minecraft version is one line in the compose file and a recreate. Your world data stays on the volume. A second server for creative mode alongside your survival world is a copy of the service with a different port. Backups are a copy of one directory. Want to start fresh? Delete the container and keep the volume. Want everything gone? Delete both.
The itzg/minecraft-server image is the community standard. It has been maintained since 2014, publishes a new release every few weeks, and handles Java version selection, server type (Vanilla, Paper, Fabric, Forge, NeoForge, Purpur and more), EULA acceptance, memory, whitelist, ops, mod and plugin downloads, and health checks.
This guide assumes Docker Engine with the Compose plugin (the docker compose command, with a space). If you do not have it yet, follow the Docker installation guide for Ubuntu 24.04 first. Check what you have with:
docker --version
docker compose version
If docker compose version errors but docker-compose works, you are on the retired Compose v1. Install the docker-compose-plugin package from Docker’s repository; every command below uses v2 syntax, and the compose files have no version: line because Compose v2 ignores it.
How much RAM does a Minecraft Docker server need?
MEMORY sets the Java heap (both -Xms and -Xmx); the image default is 1G, which is too small for most real use. The JVM also uses memory outside the heap, and the image docs recommend allowing an extra 25% on top for the container as a whole. So MEMORY: "4G" needs about 5 GB free on the host. As a starting point, 2G to 4G of heap suits a few friends on a Paper server; heavy modpacks want 6G to 8G or more. View distance and simulation distance cost more than player count, so turn those down before buying RAM.
Step 1: Basic Docker Compose Setup
Create a directory for your Minecraft server and the compose file:
mkdir -p ~/minecraft-server && cd ~/minecraft-server
Create docker-compose.yml (Compose also accepts compose.yaml, the name the image docs use):
services:
minecraft:
image: itzg/minecraft-server:latest
container_name: minecraft
restart: unless-stopped
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "LATEST"
MEMORY: "4G"
MOTD: "A Dockerised Minecraft Server"
MAX_PLAYERS: 10
DIFFICULTY: "normal"
MODE: "survival"
VIEW_DISTANCE: 10
SIMULATION_DISTANCE: 8
ENABLE_COMMAND_BLOCK: "false"
SPAWN_PROTECTION: 16
ONLINE_MODE: "true"
volumes:
- minecraft-data:/data
stdin_open: true
tty: true
volumes:
minecraft-data:
Start the server:
docker compose up -d
The container downloads Paper for the latest Minecraft release, writes eula.txt and server.properties, and starts the server. The first start takes a minute or two while it downloads and generates the world. Watch the logs:
docker compose logs -f
The server is ready when you see the “Done” line. Example output (timings and versions will differ on your machine):
minecraft | [init] Resolving type given PAPER
minecraft | [init] Starting the Minecraft server...
minecraft | [12:04:31 INFO]: Preparing level "world"
minecraft | [12:04:52 INFO]: Done (18.204s)! For help, type "help"
Press Ctrl+C to stop following the logs; the server keeps running. Then confirm the container is healthy. The image has a built-in health check (mc-health) that pings the server like a client would:
docker compose ps
docker container inspect -f "{{.State.Health.Status}}" minecraft
The second command prints starting while the world generates and healthy once players can join. In Minecraft, go to Multiplayer > Add Server and enter the Docker host’s IP address (for example 192.168.1.50). You only need to add :port when you use something other than 25565.
You do not install Java on the host. The latest image tag currently ships Java 25, which Minecraft 26.x requires (Mojang’s version manifest lists Java 25 for 26.3). For older worlds or mods, pick a tag from the Java version table: java21 for Minecraft 1.20.5 to 1.21.11, java17 for some older mod stacks, and java8 for Forge below 1.18.
Understanding the Environment Variables
Most server.properties settings map to an upper-case environment variable (view-distance becomes VIEW_DISTANCE), and the image writes them for you on every start. Edit the compose file and run docker compose up -d again to apply a change. The ones that matter most:
| Variable | What it does | Default |
|---|---|---|
EULA |
Accepts Mojang’s EULA. Required, the container exits without it. | none |
TYPE |
Server software: VANILLA, PAPER, PURPUR, FABRIC, FORGE, NEOFORGE and others |
VANILLA |
VERSION |
Minecraft version: LATEST, SNAPSHOT or a number such as 26.3 |
LATEST |
MEMORY |
Java heap, sets both -Xms and -Xmx. Use INIT_MEMORY and MAX_MEMORY to set them separately |
1G |
ONLINE_MODE |
Checks players against Microsoft accounts. Leave it on | true |
WHITELIST / OPS |
Comma or newline separated Java profile names or UUIDs | empty |
RCON_PASSWORD |
RCON password. RCON is on by default with a random password per start | random |
UID / GID |
User and group the server runs as inside the container | 1000 |
TZ |
Time zone for log timestamps, e.g. Europe/London |
UTC |
USE_AIKAR_FLAGS |
Adds Aikar’s tuned garbage-collection flags | false |
The full list is in the server properties documentation. If you would rather fill in a form, the docs point to setupmc.com’s configurator, which generates a compose file for this image (that is the “minecraft docker compose generator” people search for).
Pin the version once real players depend on the server: VERSION: "26.3". Minecraft moved to year-based numbers in 2026, so the release after 1.21.11 was 26.1, followed by 26.2 and 26.3. Paper usually lags a new Minecraft release by days or weeks, and plugins lag Paper, so LATEST can pull a version your plugins do not support yet.
Step 2: The Server Console
RCON is enabled by default in this image, so the bundled rcon-cli works with no extra setup. For an interactive console:
docker exec -i minecraft rcon-cli
Type commands without the leading slash (list, whitelist add PlayerName, op PlayerName) and press Ctrl+D to leave. For a one-off command, pass it as arguments:
docker exec minecraft rcon-cli list
docker exec minecraft rcon-cli say Restarting in 5 minutes
Because the compose file sets stdin_open and tty, you can also attach to the raw server console:
docker compose attach minecraft
Detach from an attached console with Ctrl+P then Ctrl+Q. Pressing Ctrl+C while attached sends the interrupt to the server and stops it. rcon-cli does not have this trap, which is why it is the better daily habit. Do not publish the RCON port (25575) in ports:; rcon-cli runs inside the container and does not need it.
To stop the server cleanly, use docker compose stop. The image catches the stop signal and sends stop to the server so the world is saved before the container exits.
Step 3: Whitelist and Ops Management
For a small private server, set the lists in the compose file:
environment:
# ... other variables ...
WHITELIST: "Player1,Player2,Player3"
OPS: "Player1"
ENFORCE_WHITELIST: "true"
Setting WHITELIST turns the whitelist on. ENFORCE_WHITELIST kicks anyone already online who is not on it when the list changes. Apply changes with docker compose up -d; the world is on the volume and is untouched.
One behaviour catches people out. By default the image merges the names from WHITELIST into the existing whitelist.json, so deleting a name from the compose file does not remove that player. If you want the compose file to be the single source of truth, add EXISTING_WHITELIST_FILE: "SYNCHRONIZE" (and EXISTING_OPS_FILE: "SYNCHRONIZE" for ops). If you would rather manage the list in game, leave WHITELIST out, set ENABLE_WHITELIST: "true", and use rcon-cli whitelist add.
Use Java Edition profile names, not Xbox gamertags. They can differ even for the same Microsoft account, and a gamertag on the whitelist is the usual reason a friend gets “You are not white-listed on this server!”.
Step 4: Volumes and Where Your World Lives
The compose file above uses a Docker named volume (minecraft-data). It is simple and Docker manages the path. If you want to browse and edit the files directly, use a bind mount instead:
volumes:
- ./data:/data
Everything the server owns lives under /data:
data/
server.properties
whitelist.json
ops.json
world/
world_nether/ (Paper and other Bukkit-based types)
world_the_end/ (Paper and other Bukkit-based types)
logs/
plugins/ (Paper, Purpur)
mods/ (Fabric, Forge, NeoForge)
config/
Vanilla keeps the Nether and End inside world/; Paper splits them into their own folders. Back up all three either way.
Never run the image without a volume on /data. The image declares /data as a volume, so Docker quietly creates an anonymous one, and anonymous volumes are easy to lose when the container is removed. If you already did this, the data directory docs show how to copy it into a named volume.
With a bind mount, the server runs as UID 1000 by default and the image changes ownership of /data at start. If your host user has a different UID, set UID and GID to match it (id -u and id -g show yours). On SELinux hosts or rootless Podman, add :Z to the mount.
Step 5: Mods and Plugins
Paper and Purpur use plugins, which only need installing on the server. Fabric, Forge and NeoForge use mods, which usually have to be installed on the client as well. The image can download either from Modrinth at startup, matched to your TYPE and VERSION:
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "26.3"
MODRINTH_PROJECTS: |
essentialsx
luckperms
For a Fabric server, the same variable takes Fabric mod slugs (TYPE: "FABRIC" with, for example, fabric-api and lithium). To use JAR files you already have, mount a folder on /plugins or /mods and the image copies its contents into /data on each start. Full modpacks are a separate feature (MODPACK_PLATFORM with Modrinth, CurseForge or FTB packs), covered in the types and platforms docs.
Step 6: Running Multiple Servers
Want a creative server alongside your survival world? Add a second service with its own volume and a different host port:
services:
survival:
image: itzg/minecraft-server:latest
container_name: mc-survival
restart: unless-stopped
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "26.3"
MEMORY: "4G"
MOTD: "Survival Server"
MODE: "survival"
DIFFICULTY: "hard"
VIEW_DISTANCE: 10
ONLINE_MODE: "true"
WHITELIST: "Player1,Player2,Player3"
OPS: "Player1"
ENFORCE_WHITELIST: "true"
volumes:
- survival-data:/data
stdin_open: true
tty: true
creative:
image: itzg/minecraft-server:latest
container_name: mc-creative
restart: unless-stopped
ports:
- "25566:25565"
environment:
EULA: "TRUE"
TYPE: "PAPER"
VERSION: "26.3"
MEMORY: "2G"
MOTD: "Creative Server"
MODE: "creative"
DIFFICULTY: "peaceful"
VIEW_DISTANCE: 12
ONLINE_MODE: "true"
WHITELIST: "Player1,Player2,Player3"
OPS: "Player1"
ENFORCE_WHITELIST: "true"
volumes:
- creative-data:/data
stdin_open: true
tty: true
volumes:
survival-data:
creative-data:
Both containers listen on 25565 internally; only the host side of the mapping changes. Players connect to the creative server with your-server-ip:25566. Each server has its own volume, so worlds, configs and plugins are isolated, and you can start, stop or update either one on its own:
docker compose up -d # start both
docker compose stop creative # stop just creative
docker compose logs -f survival # follow one server's logs
Budget RAM for both: 4G plus 2G of heap here means roughly 7.5 GB with the JVM overhead. If you want everyone on one address with a command to hop between worlds, that is a proxy such as Velocity, which the same author packages as itzg/mc-proxy.
Step 7: Backups
Copying world files while the server is writing them can give you a corrupt backup. The safe sequence is: turn autosave off, force a full save to disk, copy, turn autosave back on. The image author publishes a companion container, itzg/mc-backup, that does exactly that over RCON on a schedule. Add it to the same compose file:
services:
minecraft:
# ... everything from Step 1 ...
environment:
# ... existing variables ...
RCON_PASSWORD: "${RCON_PASSWORD}"
backups:
image: itzg/mc-backup
restart: unless-stopped
depends_on:
minecraft:
condition: service_healthy
environment:
RCON_HOST: minecraft
RCON_PASSWORD: "${RCON_PASSWORD}"
BACKUP_INTERVAL: "24h"
INITIAL_DELAY: 0
PRUNE_BACKUPS_DAYS: 7
TZ: "Europe/London"
volumes:
- minecraft-data:/data:ro
- ./backups:/backups
Put the password in a .env file next to the compose file so it is not in the YAML (and not in Git):
echo "RCON_PASSWORD=$(openssl rand -hex 16)" > .env
chmod 600 .env
docker compose up -d
The server needs a fixed password here because its default RCON password is regenerated on every start, and the backup container has to know it. Backups land in ./backups as dated .tgz files, and anything older than seven days is pruned. To take one now, for example before an update:
docker compose exec backups backup now
If you prefer a host cron job with a bind mount, the same safe sequence by hand looks like this:
#!/bin/bash
# backup-minecraft.sh
set -euo pipefail
BACKUP_DIR="/opt/backups/minecraft"
DATA_DIR="$HOME/minecraft-server/data"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
mkdir -p "$BACKUP_DIR"
docker exec minecraft rcon-cli save-off
docker exec minecraft rcon-cli save-all flush
tar -czf "$BACKUP_DIR/minecraft-$TIMESTAMP.tar.gz" -C "$DATA_DIR" world world_nether world_the_end
docker exec minecraft rcon-cli save-on
find "$BACKUP_DIR" -name "minecraft-*.tar.gz" -mtime +7 -delete
echo "Backup complete: minecraft-$TIMESTAMP.tar.gz"
Schedule it with crontab -e and a line such as 0 4 * * * /home/your-user/minecraft-server/backup-minecraft.sh. A backup you have never restored is a hope, not a backup: restore one into a spare volume with a second service on another port and join it once.
Step 8: Updating Minecraft and the Image
Two things update independently: the image (Java, the start scripts) and the Minecraft server itself (controlled by VERSION).
# Take a backup first
docker compose exec backups backup now
# Pull the newest image and recreate the container
docker compose pull
docker compose up -d
With VERSION: "LATEST", the server moves to the newest release whenever the container restarts. With a pinned version, change the number in the compose file and run docker compose up -d. Check the logs afterwards for the “Done” line.
Minecraft upgrades the world format on first load with a newer version, and there is no supported way back. Loading a world in an older version than it was last saved with can corrupt it. Always take a backup before changing VERSION, and keep it until you are happy with the new version.
Step 9: Firewall and Remote Access
On your LAN, nothing else is needed. For friends outside your network, forward TCP 25565 on your router to the Docker host’s LAN IP (not the container’s internal IP). If you run UFW on the host:
sudo ufw allow 25565/tcp comment 'Minecraft Server'
# Second server, if you added one:
sudo ufw allow 25566/tcp comment 'Minecraft Creative'
Docker writes its own iptables rules for published ports, and that traffic bypasses UFW’s rules. A published port is reachable even if UFW says otherwise. To limit a port to one interface, bind it in the mapping, for example "192.168.1.50:25565:25565" for LAN only. Setting "iptables": false in /etc/docker/daemon.json is not a fix for most people: it breaks container networking unless you write all the rules yourself.
If you would rather not open a port at all, a mesh VPN (WireGuard-based tools such as Tailscale or NetBird) lets invited friends reach the server’s private address. It also works when your ISP puts you behind CGNAT, where port forwarding cannot work.
Bedrock Edition: A Different Image
Players on consoles, phones and the Windows Bedrock client cannot join a Java server. Bedrock Dedicated Server has its own image, itzg/minecraft-bedrock-server, and its networking changed in 2026: from Bedrock Dedicated Server 1.26.50 the default transport is NetherNet, which uses TCP 19132 for the connection handshake and a range of UDP ports for gameplay, one per player. UDP 19132 is only used if you switch back to the old TRANSPORT=raknet. A compose version of the image’s quick start:
services:
bedrock:
image: itzg/minecraft-bedrock-server
container_name: bedrock
restart: unless-stopped
ports:
- "19132:19132/tcp"
- "19140-19155:19140-19155/udp"
environment:
EULA: "TRUE"
# Replace 192.168.1.50 with your Docker host's IP (or your public IP for internet play)
SERVER_UDP_PORTS: "192.168.1.50:19140-19155:19140-19155"
volumes:
- bedrock-data:/data
stdin_open: true
tty: true
volumes:
bedrock-data:
Use a UDP range with at least one port per player (the default max-players is 10), and forward the TCP port and the whole UDP range if people join over the internet. Older guides that only map 19132/udp will not work with current Bedrock servers. If you want Java and Bedrock players in the same world, the usual route is the Geyser plugin on a Paper server rather than two separate servers.
Advanced: JVM Tuning
You do not need to paste a page of garbage-collection flags. The image has a switch for Aikar’s widely used G1GC settings:
environment:
# ... other variables ...
MEMORY: "6G"
USE_AIKAR_FLAGS: "true"
When MEMORY is 12G or more, the image adjusts the flags as Aikar’s article recommends. There is also USE_MEOWICE_FLAGS, an updated set aimed at Java 17 and later. Extra JVM options go in JVM_OPTS, and -XX options in JVM_XX_OPTS. If you would rather the JVM size itself from a container memory limit, set MEMORY: "" and give the service a memory limit; the JVM then uses 25% of the limit by default, or a percentage you set in MAX_MEMORY (for example "75%").
Troubleshooting: Errors You Will Actually See
“Please accept the Minecraft EULA” and the container exits
The log shows Please accept the Minecraft EULA at https://account.mojang.com/documents/minecraft_eula by adding the following immediately after 'docker run': -e EULA=TRUE. Add EULA: "TRUE" to environment:, with the quotes, and run docker compose up -d.
UnsupportedClassVersionError … class file version 69.0
The Java in the image is older than the server needs. Class file version 65 means Java 21 and 69 means Java 25. Usually you are on an old cached image or pinned a java21 tag while asking for Minecraft 26.x. Run docker compose pull && docker compose up -d, or set the image tag to match the Java table. The reverse also happens: old Forge modpacks can fail on new Java, and need java17 or java8.
“Failed to verify username!”
With ONLINE_MODE on, the server checks each login with Microsoft’s session servers. This message usually means the client is not signed in with a genuine Java account (an offline or cracked launcher), the player’s launcher session has expired (signing out and back in fixes it), or the host cannot reach the session servers (check DNS and outbound HTTPS from the host). Do not “fix” it by turning ONLINE_MODE off on an internet-facing server: anyone could then join as any name, including your ops.
“Connection refused: no further information” or “Can’t connect to server”
Work outwards. Check the container is healthy (it may still be generating the world). Check the port is published with docker compose ps; the PORTS column should show 0.0.0.0:25565->25565/tcp. From another machine on the LAN, test with nc -zv 192.168.1.50 25565. If LAN works but the internet does not, it is the router’s port forward, your ISP’s CGNAT, or a firewall in front of the host.
Container keeps restarting, exit code 137
Exit code 137 means the process was killed, usually by the kernel’s out-of-memory killer. Check with docker inspect -f '{{.State.OOMKilled}}' minecraft. Lower MEMORY so heap plus overhead fits the host, or add RAM.
Permission denied on /data, or “Changing ownership of /data” hangs
Usually a bind mount owned by a different UID, or a network share that refuses chown. Match UID/GID to the owner of the host folder, add :Z on SELinux hosts, or set SKIP_CHOWN_DATA: "true" if the ownership is already correct. Set DEBUG: "true" for verbose start-up logs when you need to see what the image is doing.
Docker vs a VM vs Bare Metal for Minecraft
Performance inside a container is effectively the same as on the host: there is no hypervisor layer, the JVM runs directly on the host kernel. A VM costs some RAM for its own OS and buys you stronger isolation, which matters more if you host strangers. Bare metal skips Docker but brings back the manual Java, JAR and systemd work. For a homelab host that already runs containers, Docker is the tidy option; on a dedicated machine running only Minecraft, any of the three is reasonable.
Cheat Sheet
| Task | Command or setting |
|---|---|
| Start or apply compose changes | docker compose up -d |
| Follow logs | docker compose logs -f minecraft |
| Health | docker container inspect -f "{{.State.Health.Status}}" minecraft |
| Console | docker exec -i minecraft rcon-cli |
| One-off command | docker exec minecraft rcon-cli whitelist add Name |
| Stop cleanly | docker compose stop |
| Update image | docker compose pull && docker compose up -d |
| Backup now (sidecar) | docker compose exec backups backup now |
| Java port / Bedrock ports | TCP 25565 / TCP 19132 plus a UDP range |
| RAM rule of thumb | Host RAM for the container = MEMORY + 25% |
Why Docker Is the Best Approach
Put together, here is what you gain over a hand-built install:
- Clean separation – No Java installation on the host. No files scattered across the filesystem. Everything is in a container and a volume.
- Reproducible setup – Your compose file is your documentation. Someone else can run the same server from one file.
- Easy updates – One command. No hunting for JAR files, no Java version mismatches.
- Multiple servers – Several servers on different ports, each with its own world, without juggling systemd units.
- Portability – Move the compose file and the data to any Docker host and it runs the same way.
- Clean teardown –
docker compose down -vremoves the containers and their volumes. Back up first:-vdeletes the world too.
Docker Compose is how a lot of real applications are deployed. The workflow you have just used, defining services in YAML, keeping secrets in an .env file, persisting data in volumes, running a backup sidecar, gating it on a health check and updating by pulling a new image, is the same one teams use for databases, web apps and monitoring stacks. A Minecraft server is a low-stakes place to practise it, and “I run a stateful service in containers with scheduled, tested backups” is a sentence that holds up in an interview.
Key Takeaways
itzg/minecraft-serverhandles Java, server type, EULA andserver.propertiesthrough environment variables; you never install Java on the host- The three essentials are
EULA=TRUE, TCP port 25565 and a volume on/data - Give the host about 25% more RAM than
MEMORY, and pinVERSION(for example26.3) once players depend on the server - RCON is on by default: use
docker exec -i minecraft rcon-clifor the console instead of attaching - Back up with the
itzg/mc-backupsidecar or asave-off,save-all flush, copy,save-onscript, and test a restore - Bedrock is a separate image and now uses TCP 19132 plus a UDP port range
- Docker-published ports bypass UFW. Bind to a specific IP if a port should stay on the LAN.
Related Guides
If you found this useful, these guides continue the journey:
- Minecraft Server on Ubuntu — Set up a dedicated Minecraft server on Ubuntu Linux.
- Minecraft Server on Raspberry Pi — Run a Minecraft server on a Raspberry Pi for a low-power family server.
- Minecraft Server on Windows — Get a Minecraft server running on a spare Windows PC in minutes.
- Docker Compose Beginner’s Guide — Learn how to define and manage multi-container applications.
- Essential Docker Commands — The commands you will actually use day to day with Docker.
- How to Build Your First Homelab in 2026 — Start your self-hosting journey with a practical homelab build.
RTFM Apparel · printed in the UK

ReadTheManual is run, written and curated by Eric Lonsdale.
Eric has over 20 years of professional experience in IT infrastructure, cloud architecture, and cybersecurity, but started with PCs long before that.
He built his first machine from parts bought off tables at the local college campus, hoping they worked. He learned on BBC Micros and Atari units in the early 90s, and has built almost every PC he’s used between 1995 and now.
From helpdesk to infrastructure architect, Eric has worked across enterprise datacentres, Azure environments, and security operations. He’s managed teams, trained engineers, and spent two decades solving the problems this site teaches you to solve.
ReadTheManual exists because Eric believes the best way to learn IT is to build things, break things, and actually read the manual. Every guide on this site runs on infrastructure he owns and maintains.
Enjoyed this guide?
New articles on Linux, homelab, cloud, and automation every 2 days. No spam, unsubscribe anytime.







