Skip to Content
Alzo

Storage

A service with no volumes keeps no state, which is usually what you want for a cache. Declare volumes for anything that should outlive its container:

const db = defineService({
  name: 'db',
  ports: { pg: 5432 },
  env: { POSTGRES_PASSWORD: 'dev' },
  provision: { image: 'postgres:17' },
  volumes: {
    data: { path: '/var/lib/postgresql/data', onRemove: 'retain' },
    seed: { from: './db/seed.sql', to: '/docker-entrypoint-initdb.d/seed.sql', readOnly: true },
  },
});

Four forms cover different ownership:

  • A named volume (path) is created and managed by Alzo.
  • A bind mount (from and to) points at a path on your machine.
  • Content (content and to) writes one file that the configuration assembles.
  • A managed mirror adds sync: true to copy a host directory into a per-instance Docker volume.

Volume keys become part of Docker object names. Use 1–128 letters, digits, dots, underscores or hyphens, beginning with a letter or digit.

Retention

Named volumes are ephemeral by default, and this is the opposite of Compose. docker compose down keeps named volumes unless you pass -v; here an explicit alzo down removes them. A worktree is a disposable copy of the repository, and its data should be disposable too. Write onRemove: 'retain' when re-seeding is expensive or the data is not reproducible. Teardown says what it removed and names the field.

Stopping is not removing. Ctrl-C on alzo up and alzo stop leave volumes alone. You stop a graph dozens of times a day and delete a worktree once; the next alzo up in the same worktree costs startup time, not a re-seed.

Deleting a worktree, a project or a node declaration leaves its Docker objects in place. Inspect them with alzo plan --down --orphans and remove them with orphan cleanup. Cleanup for a checkout that no longer exists requires its exact scope and keeps its named volumes and allocation. Removal asks for confirmation in a terminal and requires -y elsewhere.

Generated files

The content form writes a file rather than mounting a path — for a file the configuration assembles, which otherwise needs a pointless detour through a temporary file:

const proxy = defineService({
  name: 'proxy',
  ports: { https: 443 },
  provision: { image: 'caddy:2' },
  volumes: {
    caddyfile: {
      content: () => `${api.hostname} { reverse_proxy ${api.address.http} }`,
      to: '/etc/caddy/Caddyfile',
      readOnly: true,
    },
  },
});

content takes a callback, like env: the file worth assembling is usually built from addresses Alzo allocates, and those are not known when you write the configuration.

Managed source mirrors

For code that must stay containerized, use a managed mirror instead of a source bind mount:

volumes: {
  source: {
    from: './src',
    to: '/app/src',
    sync: true,
    ignore: ['node_modules', '**/*.map'],
    restart: false, // default: let the application watcher/HMR react
  },
},

The initial tree lands before the application starts. Later creations, updates, renames and deletions transfer only the changed subtree. The target is a volume Alzo manages, so the application never reads through Docker Desktop's source bind mount, which is slow on macOS. Alzo packs changes before briefly pausing the owning container to update the target, journals each update so an interrupted one can be recovered, and refuses a mirror larger than 512 MiB or 100,000 paths. Interrupted copy work is stopped before the container is unpaused, and a later alzo up recovers a pause left by a crash. .git is always excluded; additional ignored paths keep whatever the image or application placed there. Set restart: true only when the process cannot watch the files itself.

Bind mounts and file ownership

A bind mount carries files both ways, which is how generated code gets out of a container — a rails generate, a rebuilt lockfile, configuration the running application edited. The catch is ownership: a container runs as root, so those files land in your worktree as root:root, and you cannot edit them without sudo.

user: 'current',   // your uid:gid — also accepts '1000:1000' or a username

It is not the default, because some images need root to start. Alzo tells you the first time a container writes a root-owned file into a bind-mounted path, and names the field.

On this page