Volumes are stored in an area of the host filesystem that’s managed by Docker.
•
Bind mounts can map to any folder in the host filesystem, so access can’t be controlled from
Docker process and can pose a security risk as a container could access sensitive OS folders.
•
tmpfs mounts are like virtual folders that only exist in the host’s mem
ory and are never written
to the filesystem.
From remote storage:
•
Azure Storage
, which provides geo-distributable storage, providing a good long-term
persistence solution for containers.
•
Remote relational databases like
Azure SQL Database
or NoSQL databases like
Azure Cosmos
DB
, or cache services like
Redis
.
From the Docker container:
•
Overlay File System . This Docker feature implements a copy-on-write task that stores updated
information to the root file system of the container. That information is “on top” of the original
image on which the container is based. If the container is deleted from the system, those
changes are lost. Therefore, while it’s possible to save the state of a container within its local
storage, designing a system around this would conflict with the premise of container design,
which by default is stateless.
However, using Docker Volumes is now the preferred way to handle local data in Docker. If you need
more information about storage in containers check on
Docker storage drivers
and
About storage
drivers
.
The following provides more detail about these options:
Volumes are directories mapped from the host OS to directories in containers. When code in the
container has access to the directory, that access is actually to a directory on the host OS. This
directory is not tied to the lifetime of the container itself, and the directory is managed by Docker and
isolated from the core functionality of the host machine. Thus, data volumes are designed to persist
data independently of the life of the container. If you delete a container or an image from the Docker
host, the data
persisted in the data volume isn’t deleted.
Volumes can be named or anonymous (the default). Named volumes are the evolution of