The Complete Guide to Docker Volumes and Persistent Storage
Containers are ephemeral. Without volumes, your data disappears on restart. Here's how persistent storage works in Docker.
The Problem with Containers
Containers are designed to be disposable. When a container stops, everything inside it is lost — including database files, uploaded images, and configuration changes.
This is by design: immutable containers are reproducible, testable, and easy to update. But your data needs to survive restarts.
Docker Volumes
A volume is persistent storage that exists outside the container lifecycle. Think of it as an external hard drive that you plug into your container.
Named Volumes
The recommended approach. Docker manages the storage location.
docker volume create mydata
docker run -v mydata:/app/data myapp
The /app/data directory inside the container is backed by the mydata volume. Stop the container, start a new one, mount the same volume — data persists.
Bind Mounts
Map a specific host directory into the container.
docker run -v /host/path:/container/path myapp
Useful for development (mount source code) but less portable than named volumes.
What Needs Volumes
Databases
PostgreSQL, MySQL, MongoDB — all store data on disk. Without a volume, your entire database is lost on restart. This is the most critical use of volumes.
File Uploads
Nextcloud files, Ghost images, Gitea repositories — anything users upload needs persistent storage.
Configuration
Some apps store configuration in files that change at runtime. These need persistence.
Logs
If you want logs to survive container restarts for debugging, mount a volume for the log directory.
Volume Best Practices
Always Use Named Volumes for Databases
Never run a database without a volume. This is the #1 self-hosting mistake beginners make.
Backup Volumes Regularly
Volumes contain your data. Back them up just like you'd back up any other storage.
Size Monitoring
Volumes can fill up. Monitor disk usage and set up alerts before you run out of space.
Use Read-Only Mounts When Possible
If a container only needs to read a file (like a config file), mount it as read-only (:ro) for extra security.
How TinyPod Handles Storage
TinyPod automatically creates and manages volumes for every app. Database volumes, file upload volumes, and configuration are all persistent by default. NVMe storage ensures fast I/O for database workloads.