Docker named volumes vs DOC (data-only-containers) : <p>Up to recent version of Docker (v1.10), we were thought that we can use DOC: <em>data-only containers</em>. So I would create such DOC (based on e.g. busybox) and use <code>--volumes-from</code> to link it to my container. You can still read about this in <a href="https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container">Docker documentation</a>.</p>

<p>With new version of docker, it is said that instead of DOC we should use <code>named volumes</code>. Here is an example of <code>docker-compose.yml</code>:</p>

<pre><code>version: '2'    
services:
  elasticsearch:
    image: elasticsearch:2.2.0
    command: elasticsearch -Des.network.host=0.0.0.0
    ports:
      - "9201:9200"
    volumes:
      - "es-data:/usr/share/elasticsearch/data"

volumes:    
  es-data:
</code></pre>

<p>Here we created and use named volume <code>es-data</code>.</p>

<p>There is still not much documentation on this new feature. I am asking:</p>

<ul>
<li>Can we replace DOC with named containers? How long volume is persisted? What if I remove the container that is using it?</li>
<li>How can we e.g. backup now? Previously, I could <code>docker run --rm --volumes-from es-data ...</code> and then <code>tar</code> it.</li>
</ul>
