title: Minecraft Docker Image: game storage persistence
body: <p>I'm trying to use <a href="https://hub.docker.com/r/webhippie/minecraft-vanilla/" rel="nofollow noreferrer">this Vanilla Minecraft docker image</a> to run a Minecraft server for friends, but can't seem to get its data to live beyond the lifetime of the container itself.</p>
  
  <p>I am running on an Ubuntu host, and on that host I have created <code>/opt/minecraft</code> where I'd like any outside-of-container persisted data to live.</p>
  
  <p>To test my approaches I would:</p>
  
  <ul>
  <li>start the container (commands provided below with each approach I tried)</li>
  <li>join the server</li>
  <li>dig a circle around myself as an indicator that I've been there</li>
  <li>disconnect from the server</li>
  <li>stop the container <code>docker stop generated_name</code></li>
  <li>start the container again using the same command as above</li>
  <li>join the server again</li>
  <li>is the circle I dug still there / has the world changed?</li>
  </ul>
  
  <p>I have yet to find an approach that doesn't lose my data. Here's what I've tried:</p>
  
  <h1>Approach 1: all in one</h1>
  
  <p>I tried just mounting <code>/opt/minecraft</code> as <code>/minecraft</code> in the container:</p>
  
  <pre><code>docker run -d -v /opt/minecraft:/minecraft -p 25565:25565 webhippie/minecraft-vanilla
  </code></pre>
  
  <h1>Approach 2: individual volumes</h1>
  
  <p>I noted in the Dockerfile that there are <a href="https://github.com/dockhippie/minecraft-vanilla/blob/master/Dockerfile#L19" rel="nofollow noreferrer">3 volumes listed</a>:</p>
  
  <pre><code>VOLUME ["/minecraft/merge", "/minecraft/world", "/minecraft/logs"]
  </code></pre>
  
  <p>So after destroying and recreating an empty <code>/opt/minecraft</code> and creating the three folders to mount, I tried this instead:</p>
  
  <pre><code>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
  </code></pre>
  
  <hr>
  
  <p>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?</p>
  
  <p>I'm also new to Minecraft. Maybe there's some nuance about the game that I'm missing, instead?</p>