When to use auto mapped Docker data volume
What is the main purpose of Docker data volume created by -v option without specified host file? For example
docker run -v /data -ti my-image. Doc says it creates a new filesystem mapped to host filesystem to persist data (at some random-ish location). I understand that. But containers also persist all data when they are stopped and started again. So what is the difference between persisted data in stopped container vs. data volume?
I understand use-case for its advanced usage to map specific host file with
One Solution collect form web for “When to use auto mapped Docker data volume”
Off the top of my head:
If you are planning on using
docker commitat some point, then an ephemeral volume like that can be used to intentionally prevent some contents from getting committed to the new filesystem image (because the contents of volumes are not preserved as part of the image).
If you will be generating a lot of temporary data and you are worried about filling up the root container filesystem, using a volume will give you more space (because your data won’t be sharing space with operating system files).