Volumes (volumes)
The volumes block allows you to define named persistent data volumes that can be shared across multiple services or replicas.
Property Reference
| Property | Type | Description |
|---|---|---|
[name] | object | The identifier for the volume. Currently, the value is an empty object for default local storage orchestration. |
How it works
Named volumes are managed by Nanokit to ensure data persistence even when containers are recreated or services are restarted. They are particularly useful for:
- Database Storage: Ensuring your data survives an upgrade or a crash.
- Shared Uploads: Allowing multiple replicas of a web service to access the same set of uploaded files.
- Caching: Storing heavy build artifacts or application caches (
node_modules, etc.).
Example: Shared Persistent Data
volumes:
uploads-data: {} # Defines a named volume
db-data: {}
services:
web:
runtime: node
volumes:
- uploads-data:/workspace/public/uploads
api:
runtime: node
volumes:
- uploads-data:/workspace/public/uploads
db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/dataCross-Provider Behavior
- Docker (Local/VPS): Nanokit creates standard Docker named volumes.
- AWS: Automatically provisions EBS volumes and attaches them to the appropriate instances.
- DigitalOcean: Provisions Block Storage volumes.
[!IMPORTANT] Data Integrity: When using
nkapp clean, all named volumes associated with the project are deleted. Usenkapp destroyto remove services while keeping your volumes intact.