title: Dockerfile: understanding VOLUME instruction
body: <p>Let's take an example.</p>
  
  <p>The following is the <code>VOLUME</code> instruction for the <code>nginx</code> image:</p>
  
  <pre><code>VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
  </code></pre>
  
  <p>Here are my questions:</p>
  
  <ol>
  <li><p>When you start the container, will these directories show up on my host? And when I stop my container, the directories will stay?</p></li>
  <li><p>If some (or all) of these directories already exist in my host, what will happen? For example, let's say the image comes with a default config file within the <code>/etc/nginx</code> directory of the container, and I also have a config file within <code>/etc/nginx</code> on my host. When the container starts, which of these files will get priority?</p></li>
  <li><p>What's the key difference between <code>-v /host/dir:container/dir</code> and <code>VOLUME</code>?</p></li>
  </ol>
  
  <p>References:</p>
  
  <ul>
  <li><a href="https://github.com/dockerfile/nginx/blob/master/Dockerfile" rel="noreferrer">https://github.com/dockerfile/nginx/blob/master/Dockerfile</a></li>
  <li><a href="http://www.tech-d.net/2014/11/03/docker-indepth-volumes/" rel="noreferrer">http://www.tech-d.net/2014/11/03/docker-indepth-volumes/</a></li>
  <li><a href="https://stackoverflow.com/questions/26050899/how-to-mount-host-volumes-into-docker-containers-in-dockerfile-during-build">How to mount host volumes into docker containers in Dockerfile during build</a></li>
  <li><a href="http://jpetazzo.github.io/2015/01/19/dockerfile-and-data-in-volumes/" rel="noreferrer">http://jpetazzo.github.io/2015/01/19/dockerfile-and-data-in-volumes/</a></li>
  </ul>