Skip to Content
Alzo

Container options

Settings that describe a container Alzo runs: resource limits, network isolation, labels, Docker-specific capabilities and network exposure.

const db = defineService({
  name: 'db',
  ports: { pg: 5432 },
  provision: { image: { context: './db', buildArgs: { PG_MAJOR: '17' } } },
  resources: { memory: '2gb', cpus: 2, shmSize: '256mb', nofile: 65536 },
});

const worker = defineService({
  name: 'worker',
  provision: { image: 'ghcr.io/acme/worker' },
  dependsOn: [db.available],
  egress: false,        // no route off the machine; `db` is still reachable by name
});

Note the provision: line. These fields describe a container Alzo creates, so declaring one on a host process is a compile error rather than a silent no-op — egress: false quietly doing nothing would be the security-relevant case.

Resource limits

shmSize is correctness rather than tuning: Postgres fails under load on Docker's 64mb default. Sizes are checked — '2gb' compiles, 'lots' does not. Limits must also survive Docker exactly: sizes resolve to positive whole bytes, CPU values to positive whole nanocpus, and nofile to a bounded positive integer. Alzo refuses a value that would be rounded, or a tiny limit that would become Docker's unlimited zero value.

Network isolation

egress: false removes a node's route to the internet — no default route, and no DNS either — while leaving it reachable by name from the rest of the graph. Use it for a worker, a consumer, or anything running code you did not write. An attached sidecar cannot set this independently: it inherits its namespace owner's egress policy, and Alzo refuses an explicit value instead of pretending Docker applied it.

It cannot be combined with ports, and that is a load error rather than a surprise. Every declared port is normally published for host access, but a node with no route off the machine is on a Docker network that cannot publish one. The two cannot both hold, so Alzo says so at load time rather than starting a container whose ports quietly do nothing.

Labels

labels puts Docker labels on the container, which is how an observability stack finds anything — Alloy, Promtail and cAdvisor all discover targets by label:

const web = defineService({
  name: 'web',
  provision: { image: 'ghcr.io/acme/web' },
  labels: { 'alloy.logs': 'true' },
});

Labels beginning alzo. are reserved — Alzo reads its own labels back to work out what it owns, so writing one is a load error.

Docker capabilities

Where Docker has a capability with no portable equivalent, it lives under container: — a closed set of fields, not a pass-through:

const transcoder = defineService({
  name: 'transcoder',
  provision: { image: 'ghcr.io/acme/transcoder' },
  container: {
    devices: ['/dev/dri:/dev/dri'],       // hardware video acceleration
    groupAdd: ['video', 'render'],
    securityOpt: ['seccomp:unconfined'],
    capAdd: ['NET_ADMIN'],
    privileged: false,
  },
});

A device or a bind-mount path names a particular machine, so a future target that cannot honour one of these fields must reject it rather than silently drop it.

Exposing a port to your network

A port can also be opened to your network, which is the one case loopback cannot serve — a phone running your app over Wi-Fi:

const metro = defineService({
  name: 'metro',
  ports: { bundler: { expose: 'lan' } },   // binds 0.0.0.0 instead of 127.0.0.1
  run: (self) => `pnpm expo start --port ${self.port.bundler}`,
});

expose is opt-in per port, and a compile error alongside internal. Everything else stays on 127.0.0.1, because a development database has the password dev.

On this page