Run a Minecraft server in Docker with itzg/minecraft-server
Run a Java Minecraft server in Docker with the itzg image: a working compose file for 26.3, the Java 25 tags, memory, RCON, updates, and fixes.
Quick answer Save the compose file below, run
docker compose up -d, and connect to port 25565.EULA: "TRUE"is required [1], the world lives in the container’s/dataso mount it from the host [2], and the default memory is only 1 GB, so setMEMORY[5]. Minecraft 26.3 needs Java 25 [19], and thelatest,stableandjava25image tags ship it [4]. I pinjava25so a laterlatestbump cannot change the Java version under a server you are not watching.
Every command and variable below comes from the itzg docs or Docker’s docs, read on 2026-11-17. I changed paths and picked values. I did not start a container while writing this, so there is no pasted log output.
A compose file for a Paper server on 26.3
The docs’ own starter file is a vanilla server with a single environment variable, EULA [1]. This is the one I would actually run:
services:
mc:
image: itzg/minecraft-server:java25
container_name: mc
pull_policy: daily
restart: unless-stopped
tty: true
stdin_open: true
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: PAPER
VERSION: "26.3"
MEMORY: 4G
DIFFICULTY: normal
MOTD: "Friends server"
OPS: |
YourJavaName
WHITELIST: |
YourJavaName
FriendJavaName
volumes:
- ./data:/data
Run docker compose up -d in that folder, then docker compose logs -f to follow startup [1]. What you should see is the server’s startup log and a ./data folder filling up with the world and config files. I have not captured that output, so check the log yourself.
Why each choice:
TYPE: PAPER. The Paper page says this downloads and runs Paper, and withVERSIONunset it picks the newest Minecraft version Paper supports [8]. Paper’s API lists 26.3 as supported with a minimum Java of 25 [16]. Drop both lines and you get the vanilla server, which is the image default [1][6]. For which type to pick, see vanilla vs Fabric vs Paper.VERSION: "26.3". The docs acceptLATEST,SNAPSHOT, or a version such as26.1in the new numbering [3]. Pinning means a restart never moves you to a new Minecraft version by surprise. WithLATESTorSNAPSHOT, a restart downloads the newer jar if there is one, and old jars pile up in/datawhere it is safe to delete them [3].container_name: mc. The docs’ console examples assume the container is calledmc[9]. Compose otherwise generates a name [13].restart: unless-stopped. From the docs’ data-directory example [2].WHITELISTandOPS. Read the next section before skipping these.
The whitelist default changed in 26.3
On a bare 26.3 server, white-list defaults to true [15]. The itzg variables page lists ENABLE_WHITELIST with a default of false [6], and says that setting WHITELIST or WHITELIST_FILE turns the whitelist on [7]. I did not run a container to see which wins when you set nothing. So set WHITELIST and OPS yourself, and open ./data/server.properties after first boot to check the white-list line. Use Java profile names, not Xbox gamertags [7]. More on the game side: whitelist and permissions.
Pick the Java tag on purpose
The tag decides the Java version, and that has to match what the Minecraft version requires. From the docs’ table [4]:
| Tag | Java | Use it for |
|---|---|---|
latest, stable, java25 |
25 | Current Minecraft, including 26.x |
java21 |
21 | Older servers that need 21 |
java17 |
17 | Some older modded packs (the docs say some mods up to 1.21 need Java 17) |
java8 |
8 | Forge below 1.18 (the docs say you must use a Java 8 tag) |
The docs say latest “shifts” to whatever Java the newest Minecraft needs [4]. That is the reason I prefer an explicit tag: with pull_policy: daily, Compose checks the registry for a newer image when it starts the service if the last pull was more than 24 hours ago [13], so a floating tag can change Java on you at some later restart. The alpine and jdk variants exist too; I have not tested them [4].
The class file version error. If startup logs UnsupportedClassVersionError ... class file version, the Java inside the image is older than the server jar wants [4]. The itzg docs show it for class file 65.0 with a Java 21 fix. Java 25 is class file version 69.0 in the Java Version Almanac table [14], and the Java SE 25 class file spec gives 69 as the highest supported major version [20]. On 2026-11-17 I downloaded the 26.3 server.jar from the URL in Mojang’s manifest [19] and read the header of net/minecraft/bundler/Main.class: major version 69. So on a Java 21 image the error should carry 69.0 where the docs’ example shows 65.0, and the fix is the same: re-pull and use java25 [4]. I did not run that failure, so the exact log line is not captured.
Keep the world on the host
The server stores everything under /data. That path is pre-declared as a volume, so with no mount it becomes an anonymous volume that is subject to removal when the container is removed [2]. That is the mistake to avoid: your world in a volume you did not name. The compose file above mounts ./data:/data, and the docs say the right-hand side must always be /data [2]. With SELinux, AppArmor or rootless Podman, append :Z to the mapping [2].
Already started without a mount? The docs have a procedure: stop the container, copy the anonymous volume into a named one with a temporary Alpine container, then recreate the server on the named volume [2]. Its first two steps, for a container called mc:
docker stop mc
docker run --rm --volumes-from mc -v mc:/new alpine cp -avT /data /new
Then recreate with -v mc:/data [2]. For backups of whatever you mounted, see automating Minecraft server backups.
Memory: the default is too small
The image declares a 1 GB initial and maximum heap by default. MEMORY sets both, and INIT_MEMORY and MAX_MEMORY set them separately [5]. 1 GB is not enough for real play, so raise it. How much depends on players and plugins, see how much RAM a server needs.
MEMORY only caps the Java heap. If you also set a container limit, give the container about 25% more than MEMORY, because the JVM uses memory outside the heap and the docs cite 25% extra as general best practice [5]. In Compose that limit is mem_limit [13]:
environment:
MEMORY: 4G
mem_limit: 5G
Setting the limit equal to MEMORY leaves no room for non-heap memory, which the docs say the container limit should cover [5]. My reading is that the process can then be killed under load; I did not test it. What happens when a limit is hit is covered in OutOfMemoryError vs “not responding”. Extra JVM arguments go in JVM_OPTS, -XX flags in JVM_XX_OPTS [5]. Whether to use them is a separate question: Aikar’s flags explained.
Console, RCON and plugins
RCON is enabled by default, so rcon-cli works inside the container [9]:
docker exec -i mc rcon-cli # interactive; -i is required
docker exec mc rcon-cli stop # one-shot; -i not needed
For docker attach, enable TTY and stdin (both are in the compose file above), attach with docker attach mc, and detach with Control-p Control-q [9]. The variables page says to change RCON_PASSWORD, which is randomly generated by default [6]. Do not publish port 25575. Compose warns that a ports entry without a host IP binds to every interface and bypasses host firewall rules, which can expose the container to the internet on a public IP [13]. More in Minecraft RCON setup and security.
Plugins: with ./data on the host, put jars in ./data/plugins, or mount a separate /plugins volume. A restart is needed to pick up plugins added while it runs [8]. Mods work the same way through /mods for loader-based types [10]. The docs also have an auto-download option for Spigot resources (SPIGET_RESOURCES) [8], which I did not use.
Updating
Server version: change VERSION and run docker compose up -d. Compose notices the changed configuration and recreates the container while preserving mounted volumes [11]. Image: docker compose pull fetches new images without starting containers [12] (pull_policy: daily does the same check at start time when the last pull is over 24 hours old [13]), then docker compose up -d applies it. Back up first. The walkthrough for the safe order is in updating without losing your world.
When it does not start
- Container exits straight away. Run
docker compose logsbefore anything else. The docs say to always setEULA=TRUE[1]; I have not captured the exact message you get without it. class file versionerror. Java too old for the jar. Usejava25for 26.x, as above [4].Bind for ... failed: port is already allocated. Another container or process holds the host port [17]. Change the left side of the mapping ("25566:25565"), not the server’s own port, and see Failed to bind to port.- Permission denied writing
/data. The image runs as user and group1000by default (UIDandGID) [6], so a host folder owned by someone else can fail.chown -R 1000:1000 ./datais the usual fix. That fix is my advice; the docs do not state it. - Container killed under load, with a memory limit set. A likely cause is
MEMORYset equal to the limit (untested here), see the memory section [5].
Not covered
- The Bedrock server. The README says this image supports Java natively and points to a separate Bedrock image [18].
- Kubernetes, autopause, and modpack installers.
- Port forwarding and firewalls for players outside your network: self-hosting on your own PC.
Questions people ask
Do I have to set EULA=TRUE?
Yes. The image docs say to always include it because Mojang/Microsoft requires EULA acceptance, and the variables page marks EULA as required [1][6].
Where does my world live, and does it survive removing the container?
Under the container's /data path [2]. With nothing mounted, /data is an anonymous volume that is subject to removal when the container is removed [2]. Mount a host directory or a named volume there.
Which image tag runs Minecraft 26.3?
26.3 needs Java 25 [19], and the latest, stable and java25 tags all ship Java 25 [4]. The java21, java17 and java8 tags do not run it.
How do I run commands like op or stop?
Use rcon-cli inside the container, for example docker exec mc rcon-cli stop, or docker exec -i mc rcon-cli for an interactive console [9].
Sources
- itzg/docker-minecraft-server docs: Intro (docs/index.md)
- itzg/docker-minecraft-server docs: Data directory
- itzg/docker-minecraft-server docs: Minecraft versions
- itzg/docker-minecraft-server docs: Java versions and image tags
- itzg/docker-minecraft-server docs: JVM options
- itzg/docker-minecraft-server docs: Variables
- itzg/docker-minecraft-server docs: Server properties (MOTD, whitelist, ops, seed)
- itzg/docker-minecraft-server docs: Paper
- itzg/docker-minecraft-server docs: Sending commands, with Docker
- itzg/docker-minecraft-server docs: Mods and plugins
- Docker docs: docker compose up
- Docker docs: docker compose pull
- Docker docs: Compose services reference (ports, pull_policy, mem_limit)
- Java Version Almanac: class file versions
- server.properties (Minecraft Wiki)
- Paper downloads API: version 26.3
- Failed to Bind to Port Error on Minecraft Server (Sparked Host)
- itzg/docker-minecraft-server README
- Minecraft 26.3 version manifest (Mojang, javaVersion field)
- Java SE 25 Virtual Machine Specification, chapter 4: class file format