<p>i'm new to docker and i'm trying to understand persistent storage in docker.</p>

<p>in the section <em>Manage Application data > Store data within containers > About storage drivers</em></p>

<blockquote>
  <p><a href="https://docs.docker.com/storage/storagedriver/" rel="nofollow noreferrer">https://docs.docker.com/storage/storagedriver/</a> <br>Storage drivers allow
  you to create data in the writable layer of your container. The files
  won’t be persisted after the container is deleted, and both read and
  write speeds are lower than native file system performance.</p>
</blockquote>

<p>but later on the section <em>Manage Application data > Store data within containers > Use the Device Mapper storage driver</em>
<a href="https://docs.docker.com/storage/storagedriver/device-mapper-driver/" rel="nofollow noreferrer">https://docs.docker.com/storage/storagedriver/device-mapper-driver/</a>
<br>they use direct-lvm that creates logical volumes that allow to persist data</p>

<p><strong>my question :</strong>  using a storage driver means :</p>

<ol>
<li>the container-generated data is ephemeral ?</li>
<li>the container-generated data is ephemeral if we are using a logical
volume on a loopback-device ?</li>
<li>the container-generated data is persistent if we are using a logical
volume on a block device ?</li>
</ol>

AMAR BESSALAH
<p>The storage driver configuration is essentially an install-time setting that's not really relevant once you've gotten it set up correctly.  In particular if you run <code>docker info</code> and it says it's using an <code>overlay2</code> driver I would recommend closing this particular browser tab and not changing anything.</p>

<p>Of the paragraph you quoted, the important thing to take away is that files you create inside a container, that aren't inside a volume directory, will be lost as soon as the container is deleted.  It doesn't matter what underlying storage driver you're using.  The performance differences between the container filesystem, named volumes, and bind-mounts almost never matter (except on MacOS hosts where bind mounts are very very slow).</p>

<p>The data the storage driver persists includes both the temporary container filesystems (they get persisted until the container is deleted) and the underlying image data.  It does not include named Docker volumes or other bind-mounted host directories.</p>

<p>If you're using devicemapper, you might see if you can upgrade your host to a newer Linux distribution that can use the overlay2 driver.  In particular that avoids the fixed space limit of the devicemapper driver.  If you must use devicemapper, general wisdom has been that using a dedicated partition for it is better than using a file.  As I said up front, though, this is essentially install-time configuration and has no bearing on your application or <code>docker run</code> commands.</p>
