Minecraft Docker Image: game storage persistence
I’m trying to use this Vanilla Minecraft docker image to run a Minecraft server for friends, but can’t seem to get its data to live beyond the lifetime of the container itself.
I am running on an Ubuntu host, and on that host I have created
/opt/minecraft where I’d like any outside-of-container persisted data to live.
To test my approaches I would:
- start the container (commands provided below with each approach I tried)
- join the server
- dig a circle around myself as an indicator that I’ve been there
- disconnect from the server
- stop the container
docker stop generated_name
- start the container again using the same command as above
- join the server again
- is the circle I dug still there / has the world changed?
I have yet to find an approach that doesn’t lose my data. Here’s what I’ve tried:
Approach 1: all in one
I tried just mounting
/minecraft in the container:
docker run -d -v /opt/minecraft:/minecraft -p 25565:25565 webhippie/minecraft-vanilla
Approach 2: individual volumes
I noted in the Dockerfile that there are 3 volumes listed:
VOLUME ["/minecraft/merge", "/minecraft/world", "/minecraft/logs"]
So after destroying and recreating an empty
/opt/minecraft and creating the three folders to mount, I tried this instead:
docker run -d -v /opt/minecraft/world:/minecraft/world -v /opt/minecraft/merge:/minecraft/merge -v /opt/minecraft/logs:/minecraft/logs -p 25565:25565 webhippie/minecraft-vanilla
In both approaches 1 and 2 I can see that some files have been created in the folder(s) mounted as volumes (so I don’t think it’s a permissions issue), but it doesn’t seem to be enough to keep my world from being created from scratch again after a container restart. What am I missing?
I’m also new to Minecraft. Maybe there’s some nuance about the game that I’m missing, instead?
One Solution collect form web for “Minecraft Docker Image: game storage persistence”
Your second approach should be totally fine to keep the world, at least that’s how I’m doing that.