Docker Volumes
Uncloud uses native Docker volumes for persistent storage. Volumes provide a way to store data that survives container restarts and updates.Volume Types
Uncloud supports three types of volumes:Named Volumes
Managed by Docker, stored in Docker’s volume directory:Bind Mounts
Mount a host directory directly into the container:Tmpfs Mounts
Store data in memory (not persistent):Named volumes and bind mounts provide persistence. Tmpfs mounts do not persist data across container restarts.
Volume Lifecycle
Creating Volumes
Volumes can be created:- Automatically during deployment:
- Manually before deployment:
Listing Volumes
View all volumes across the cluster:- Volume name
- Driver (usually
local) - Which machine the volume is on
Removing Volumes
Delete a volume:Volume Placement
Volumes exist on a specific machine and cannot be automatically moved or shared between machines.Single Machine Constraint
When you use a volume:- Creates the volume on the target machine
- Ensures the container is placed on that machine
- Prevents the container from being scheduled elsewhere
Services with volumes typically use
replicas: 1 since the volume only exists on one machine.Explicit Placement
You can specify which machine should host the volume:storage-server.
Stateful Services
Single Replica Stateful Services
For databases and other stateful applications:- Use
replicas: 1since volumes are machine-local - Set
update_config.order: stop-firstto prevent data corruption - The old container stops before the new one starts, using the same volume
Uncloud defaults to
stop-first update order for services with volumes to prevent concurrent access to the volume.Read-Only Volumes
Mount volumes as read-only to prevent accidental modifications::ro suffix makes the mount read-only inside the container.
Volume Drivers
Uncloud supports different volume drivers for various storage backends.Local Driver (Default)
Thelocal driver stores data in a directory on the machine:
/var/lib/docker/volumes/mydata/_data on the machine.
Custom Driver Options
Configure driver-specific options:NFS and other network storage drivers allow multiple machines to access the same volume, enabling stateful services to move between machines.
Multi-Machine Storage Strategies
Since Docker volumes are machine-local, you need additional strategies for multi-machine deployments.Replicated Stateless Services
Avoid volumes entirely for stateless services:- External database services
- Object storage (S3, MinIO)
- Caching services (Redis, Memcached)
Database Per Machine
Run a database replica on each machine:Network Storage
Use NFS, GlusterFS, or Ceph for shared volumes:Object Storage
For static files, use object storage like S3:Volume Management
Volume Labels
Add metadata to volumes:Volume Inspection
View detailed volume information:- Volume name and driver
- Mount point on the host
- Labels and options
- Which machine it’s on
Volume Pruning
Remove unused volumes:Backup and Restore
Uncloud doesn’t provide built-in backup tools, but you can use standard Docker and Linux tools.Backup Strategies
Manual Backup
Create a backup container:Automated Backups
Run a backup service:Database-Specific Tools
Use database native tools:Restore Process
- Create new volume:
- Restore data:
- Update service to use restored volume:
Always test your backup and restore procedures before relying on them in production.
Storage Performance
Local Driver Performance
The defaultlocal driver uses the host filesystem:
- Performance matches the underlying disk (SSD, HDD, etc.)
- No additional overhead beyond Docker’s volume management
- Best performance for most use cases
Network Storage Performance
NFS and similar network storage:- Higher latency than local storage
- Throughput limited by network bandwidth
- Suitable for shared configuration files, not high-IOPS databases
Storage Optimization
For better performance:- Use local SSDs for database volumes
- Avoid network storage for high-throughput workloads
- Use tmpfs for temporary data that doesn’t need persistence
- Tune filesystem options based on your workload
Best Practices
Do:
- Use named volumes for persistent data
- Set
update_config.order: stop-firstfor stateful services - Regularly backup important volumes
- Test restore procedures before you need them
- Use read-only mounts when containers don’t need write access
- Document which machine volumes are on
Don’t:
- Don’t rely on container filesystem for persistent data
- Don’t run multiple replicas with the same volume
- Don’t use tmpfs for data that needs to persist
- Don’t assume volumes will automatically move between machines
- Don’t forget to backup before major operations
Further Reading
Services
Learn about deploying stateful services
Machines
Understand machine placement and roles
Volume Commands
Creating and managing volumes with the CLI
Docker Volumes
Official Docker volumes documentation
