title: Combing VOLUME + docker run -v
body: <p>I was looking for an explanation on the VOLUME entry when writing a Dockerfile and came across this statement</p>
  <blockquote>
  <p>A volume is a persistent data stored in <code>/var/lib/docker/volumes/...</code></p>
  <p>You can either declare it in a <code>Dockerfile</code>, which means each time a container is started from the image, the volume is created (empty), even if you don't have any <code>-v</code> option.</p>
  <p>You can declare it on runtime <code>docker run -v [host-dir:]container-dir</code>.
  combining the two (<code>VOLUME</code> + <code>docker run -v</code>) means that you can mount the content of a host folder into your volume persisted by the container in <code>/var/lib/docker/volumes/...</code></p>
  <p><code>docker volume create</code> creates a volume without having to define a <code>Dockerfile</code> and build an image and run a container. It is used to quickly allow other containers to mount said volume.</p>
  </blockquote>
  <p>But I'm having a hard time understanding this line:</p>
  <blockquote>
  <p>...combining the two (<code>VOLUME</code> + <code>docker run -v</code>) means that you can mount the content of a host folder into your volume persisted by the container in <code>/var/lib/docker/volumes/...</code></p>
  </blockquote>
  <p>For example, let's say I have a config file on my host machine and I run the container based off the image I made with the <code>Dockerfile</code> I wrote. Will it copy the config file into where the volume that I stated in my the volume entry?</p>
  <p>Would it be something like (pseudocode)</p>
  <pre><code>#dockerfile
  From Ubuntu
  
  Run apt-get update
  
  Run apt-get install mysql
  
  Volume . /etc/mysql/conf.d
  
  Cmd systemcl start MySQL
  </code></pre>
  <p>And when I run it</p>
  <pre><code>docker run -it -v /path/to/config/file:  ubuntu_based_image
  </code></pre>
  <p>Is this what they mean?</p>