Skip to content

Volumes (volumes) ​

The volumes block allows you to define named persistent data volumes that can be shared across multiple services or replicas.

Property Reference ​

PropertyTypeDescription
[name]objectThe 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:

  1. Database Storage: Ensuring your data survives an upgrade or a crash.
  2. Shared Uploads: Allowing multiple replicas of a web service to access the same set of uploaded files.
  3. Caching: Storing heavy build artifacts or application caches (node_modules, etc.).

Example: Shared Persistent Data ​

yaml
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/data

Cross-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. Use nkapp destroy to remove services while keeping your volumes intact.