Running a Minecraft Server in Docker: Step-by-Step Guide
Running a Minecraft server used to mean downloading Java, fiddling with ports, and manually managing world saves. With Docker, you can run a fully isolated, reproducible Minecraft server in just a few commands — and keep it persistent and portable.
This guide walks through setting up a Minecraft server using Docker, with persistent data and proper networking.
Step 1: Pull the Minecraft Server Image
The easiest way to get started is by using a pre-built Minecraft server image from Docker Hub. For example, the popular itzg/minecraft-server image:
docker pull itzg/minecraft-server
This image includes:
- The latest Minecraft server
- Java runtime
- Default configuration ready to use
Using pre-built images saves time and avoids manual setup.
Step 2: Create a Data Volume
You’ll want to persist your world and server configuration so that it survives container restarts:
docker volume create mc_data
This volume will store:
- World files
- Player data
- Server.properties and other configs
Without a volume, every time the container is removed, your world disappears.
Step 3: Run the Minecraft Server Container
Now, start the server using the volume and expose the default Minecraft port (25565) to the host:
docker run -d \
-p 25565:25565 \
-v mc_data:/data \
-e EULA=TRUE \
--name mc_server \
itzg/minecraft-server
Explanation:
-d→ Run container in detached mode-p 25565:25565→ Map Minecraft port to host-v mc_data:/data→ Persist server data-e EULA=TRUE→ Accept Minecraft’s EULA--name mc_server→ Name the container for easy reference
The server will start in the background, and logs can be viewed using:
docker logs -f mc_server
Step 4: Configure Server Settings
All server configuration files live inside the volume. You can change settings like:
server.properties→ Game mode, difficulty, max playersops.json→ Define server adminswhitelist.json→ Control who can join
Since the data is stored in mc_data, changes persist even if you restart or rebuild the container.
Step 5: Updating the Server
To update to a newer Minecraft version:
- Stop the container:
docker stop mc_server
- Pull the latest image:
docker pull itzg/minecraft-server
- Start the container again using the same volume:
docker run -d \
-p 25565:25565 \
-v mc_data:/data \
-e EULA=TRUE \
--name mc_server \
itzg/minecraft-server
All your world data and settings remain intact, thanks to the persistent volume.
Step 6: Advanced Options
You can customize your server further using environment variables:
VERSION→ Specify a Minecraft versionMEMORY→ Allocate RAM (e.g.,-e MEMORY=2G)TYPE→ Vanilla, Paper, Spigot, etc.
Example with custom RAM and Paper server:
docker run -d \
-p 25565:25565 \
-v mc_data:/data \
-e EULA=TRUE \
-e MEMORY=2G \
-e TYPE=PAPER \
--name mc_server \
itzg/minecraft-server
This lets you optimize performance and tweak gameplay without touching the host system.
Step 7: Connecting to Your Server
Once the container is running:
- Use your host machine IP and port
25565in Minecraft - Players on your network or with port forwarding enabled can join
Docker handles networking, so multiple containers or applications on the same host can coexist without conflicts.
Step 8: Stopping and Removing the Server
To stop the server gracefully:
docker stop mc_server
To remove the container without losing data:
docker rm mc_server
Your world stays safe inside the mc_data volume.
Small Setup, Big Fun
With Docker, running a Minecraft server becomes:
- Quick and repeatable
- Isolated from your main system
- Persistent with volumes
- Easy to update and manage
Whether it’s a personal server for friends or a small public server, Docker makes running Minecraft cleaner, safer, and far more convenient.