All Minecraft server files are stored in the container’s /data directory. Proper data directory management ensures your worlds, configurations, and player data persist across container restarts.
Data Directory Structure
Everything the container manages is located under /data:
- World files and saves
- Server configuration (
server.properties)
- Plugin and mod files
- Player data
- Server logs
The /data path is pre-declared as a volume. If you don’t configure volume mapping, Docker will create an anonymous volume that may be deleted when the container is removed.
Bind Mounts (Recommended)
The most common approach is to use bind mounts to map a host directory to the container’s /data directory.
Using Docker Run
docker run -d \
-v /home/user/minecraft-data:/data \
-e EULA=TRUE \
-p 25565:25565 \
itzg/minecraft-server
Breaking down the volume syntax:
-v /home/user/minecraft-data:/data
------------------------- -----
| |
| +-- Must always be /data
|
+-- Replace with your host directory path
Using Docker Compose
With Docker Compose, you can use relative paths:
services:
mc:
image: itzg/minecraft-server:latest
ports:
- "25565:25565"
environment:
EULA: "TRUE"
volumes:
# Relative directory - automatically created
- ./minecraft-data:/data
tty: true
stdin_open: true
restart: unless-stopped
Docker automatically creates the minecraft-data directory relative to the compose file location if it doesn’t exist.
Special System Configurations
Rootless Containers
When running rootless containers with Podman, SELinux, or AppArmor, append :Z to the volume mapping:
# Rootless with Podman
podman run -d \
-v /home/user/minecraft-data:/data:Z \
-e EULA=TRUE \
itzg/minecraft-server
# Docker Compose with SELinux
services:
mc:
image: itzg/minecraft-server
volumes:
- ./minecraft-data:/data:Z
The :Z option relabels the content so it can be shared between containers. Use with caution in multi-container setups.
Anonymous Volumes
If you start a container without specifying a volume, Docker creates an anonymous volume automatically:
# This creates an anonymous volume
docker run -d --name mc -e EULA=TRUE itzg/minecraft-server
Anonymous volumes are convenient for testing but are subject to removal when the container is deleted.
Converting Anonymous to Named Volume
If you started with an anonymous volume, you can migrate the data to a named volume:
Stop the existing container
Copy data to named volume
Use a temporary container to copy the anonymous volume’s content:docker run --rm \
--volumes-from mc \
-v mc:/new \
alpine cp -avT /data /new
Recreate container with named volume
docker run -d -it --name mc-new \
-v mc:/data \
-p 25565:25565 \
-e EULA=TRUE \
-e MEMORY=2G \
itzg/minecraft-server
Locating Anonymous Volume Data
To find where an anonymous volume is stored on the host:
docker inspect -f "{{json .Mounts}}" CONTAINER_NAME_OR_ID
The Source field shows the host filesystem path.
Example output:
[
{
"Type": "volume",
"Name": "a1b2c3d4e5f6...",
"Source": "/var/lib/docker/volumes/a1b2c3d4e5f6/_data",
"Destination": "/data",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
]
On Windows with WSL, the volumes path is \\wsl$\docker-desktop-data\data\docker\volumes
Editing Configuration Files
With bind mounts, you can edit server files directly on the host:
Edit files on host
# Edit server.properties
nano /home/user/minecraft-data/server.properties
Best Practices
- Always use named volumes or bind mounts for production servers
- Use relative paths in Compose files for portability
- Backup the
/data directory regularly before major changes
- Use
:Z suffix when required by your system security policies
- Document your volume paths for team members
Volume Backup
Regularly backup your data directory:
# Create backup
tar -czf minecraft-backup-$(date +%Y%m%d).tar.gz /home/user/minecraft-data
# Restore from backup
tar -xzf minecraft-backup-20260301.tar.gz -C /
Troubleshooting
Permission Issues
If you encounter permission errors:
# Check ownership
ls -la /home/user/minecraft-data
# Fix permissions (adjust UID/GID as needed)
sudo chown -R 1000:1000 /home/user/minecraft-data
Data Not Persisting
Verify your volume mapping:
# Check container mounts
docker inspect -f "{{json .Mounts}}" mc | jq
# Verify data exists in host directory
ls -la /home/user/minecraft-data