Running a Minecraft Server With Docker
A containerized server starts the same way every time, on any machine with Docker installed — no manually matching Java versions by hand.
Running a Minecraft Server With Docker
The same server, the same Java version, the same config — on a laptop or a VPS, without manually setting up the environment each time.
Running a Minecraft server in Docker packages the server, its Java runtime, and its dependencies into a container that behaves identically regardless of the host machine — useful for consistency across development and production, or just avoiding a manual Java install.
Install Docker
On a Linux host:
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USERLog out and back in for the group change to take effect.
Using an Existing Minecraft Docker Image
The itzg/minecraft-server image is a widely-used, well-maintained option that handles the EULA, server type selection, and most common configuration through environment variables:
docker run -d \
-p 25565:25565 \
-e EULA=TRUE \
-e TYPE=PAPER \
-e MEMORY=4G \
-v /home/mc/data:/data \
--name mc-server \
itzg/minecraft-server-v /home/mc/data:/data maps the container's world/plugin data to a real folder on the host, so it persists even if the container is removed and recreated.
Using Docker Compose Instead
For easier long-term management, a docker-compose.yml is usually cleaner than a long docker run command:
version: "3.8"
services:
mc:
image: itzg/minecraft-server
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: "PAPER"
MEMORY: "4G"
volumes:
- ./data:/data
restart: unless-stoppedThen start it with:
docker compose up -drestart: unless-stopped automatically restarts the container if it crashes or the host reboots.
Installing Plugins in a Containerized Server
Plugins go in the mapped volume's plugins/ folder on the host (/home/mc/data/plugins in the example above) — they're accessible directly from the host filesystem, the same as a non-containerized server, since the volume mount makes them visible on both sides.
Accessing the Server Console
docker attach mc-serverattaches to the running container's console — Ctrl+P then Ctrl+Q detaches without stopping the server (regular Ctrl+C would stop it).
Or, for sending a single command without a full attach:
docker exec mc-server rcon-cli say Hello from the host(requires RCON enabled, which the itzg/minecraft-server image supports via additional environment variables).
Why Containerize at All
- Consistent Java version and environment regardless of host OS
- Easy to tear down and recreate without losing world data (as long as the volume is preserved)
- Simple to run multiple isolated servers on one host, each in its own container with its own port mapping