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 -v /data:/data/host.

  • Terminal (bash?) / Docker: logic behind - and --
  • Supervisor on a Digital Ocean docker image
  • Docker: save - produces no output
  • How can i upload data to docker (container)?
  • restore postgres within docker
  • Docker environmental variables sharing
  • Docker workflow for automated builds on Github-Dockerhub
  • Unable to set net.bridge.bridge-nf-call-iptables within Docker container
  • Permission Denied while trying to connect to Docker Daemon while running Jenkins pipeline in Macbook
  • Docker for windows failing to start
  • docker: driver failed programming external connectivity on endpoint webserver
  • Docker - MySQL commands within Dockerfile using RUN (ERROR 2002)
  • One Solution collect form web for “When to use auto mapped Docker data volume”

    Off the top of my head:

    1. If you are planning on using docker commit at 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).

    2. 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).

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.