# devops / docker / data
Persistent Data with Storage & Volumes
Containers are temporary by nature. A volume is a storage mechanism that lives outside of containers, ensuring your data remains completely safe even if the container is stopped, deleted, or recreated.
Ways to Store Data
Docker provides multiple mechanisms to manage data. Choosing the right one depends on whether you want Docker to manage the storage, or if you need direct access from the host OS.
Docker Volume
Fully managed by Docker and stored securely under /var/lib/docker/volumes. This is the best choice for persisting database files or app data.
Bind Mount
Maps a specific host directory directly to a directory inside the container. Great for local development when you want code changes to reflect instantly.
tmpfs
Stores data directly in RAM, making it blazing fast but completely temporary. Once the container stops, the data vanishes. Perfect for sensitive secrets or cache.
Volume Drivers
Available Drivers
- local
The default. Stores files natively on the local host machine.
- NFS
Uses remote Network File System storage, allowing data to be shared across multiple Docker hosts.
- type=tmpfs
Forces the storage into RAM for high-speed, non-persistent access.
- type=none
Used explicitly for bind mounts, signaling that Docker does not manage the lifecycle of this storage.
docker volume create --driver local \ -o type=tmpfs -o device=tmpfs myvol
Storage Commands Cheat Sheet
Master these commands to create, mount, inspect, and clean up your Docker volumes.