Skip to main content

Containers

A container is a Linux system that shares its node's kernel instead of booting its own. It runs a full distribution (systemd, SSH, packages, users) like a VM, but it needs a fraction of the memory and starts in about a second. Where memory runs out first, that means many more small services per node.

Containers live on the Virtual machines page next to your VMs, marked Container. To run a Docker image rather than a Linux distribution, see Apps. Protection, replication and failover work for them exactly as for VMs.

Container or VM?​

ContainerVirtual machine
MemoryOnly what its programs use, often 20-100 MB for a small serviceEverything you give it, plus its own kernel
Starts inAbout a second10-30 seconds
Operating systemsLinux only, from the image catalogAny: Linux, Windows, BSD, appliances from an ISO
IsolationShares the node's kernel: a kernel flaw could let it reach the nodeIts own kernel and virtual hardware
MovesRestart on the other node (a few seconds)Can also move live, without stopping
ConsoleTerminal, Root shell, Files, Boot logAlso Screen

Choose a container for Linux services you trust: DNS, Home Assistant core, databases, reverse proxies, file shares. Choose a VM for Windows or other operating systems, anything that needs its own kernel or kernel modules, anything exposed to the internet that you'd rather keep isolated, and anything that runs Docker (see Limits).

Create a container​

  1. Click New VM and choose Container at the top of the dialog.
  2. Fill in Name, then choose the Operating system and Version. Only images with a container build are listed. Your saved images lists images saved from containers.
  3. Set CPU limit, Memory limit and Disk (GiB) (1 CPU, 512 MiB and 8 GiB to start with; memory from 256 MiB). A container uses only what it needs up to these limits.
  4. Fill in Sign-in and, optionally, Address, VLAN and Run on, as for a VM (see Create a VM). Tick Use the node's GPU for hardware video (see Use the node's GPU).
  5. Leave Protect this container ticked to keep a copy on another node and start it there if its node fails.
  6. Click Create container. It starts on its own.

Containers need every node in the cluster online and running staxmax 0.2 or later. Until then, creating one says so: a node on an older version doesn't see containers, so it could neither stop one when it is cut off nor take one over.

What works the same​

Start, stop and restart, Edit (CPUs, memory, disk, disk speed, data disks, VLANs and network cards, scheduled snapshots, start order, backups, notes), snapshots, Clone, Reinstall, Save as image, backups and downloads, USB devices, protection, moves, maintenance mode, failover and force start all work as described in Virtual machines.

A clone, or a container made from a saved image, gets its own MAC address, machine ID and hostname, as a VM does. Its Root shell and Files tabs work without installing anything: Incus reaches into a container directly, with no agent.

Use the node's GPU​

A container can use the GPU of the node it runs on, usually the graphics built into the CPU, for hardware video encoding and decoding. Media servers such as Jellyfin and Plex use it to transcode, Frigate and Immich to decode camera streams and videos, at a fraction of the CPU it would otherwise take.

Tick Use the node's GPU when you create the container, or later under ⋯ → Edit → More; it changes while the container runs. The container then sees the GPU's devices under /dev/dri (such as renderD128), readable by every user inside it, so a service running as its own user can open them. Install the video drivers inside the container as on any Linux machine: for Intel and AMD graphics, the distribution's VA-API packages (on Debian and Ubuntu, mesa-va-drivers for AMD, intel-media-va-driver for Intel), then point the app at /dev/dri/renderD128.

Every container on a node can use its GPU at the same time. A VM can't: this option is for containers only.

Each node's GPU is listed on its card on the Nodes page. A container that uses the GPU can only start on a node that has one:

  • Its copy goes to a node with a GPU when there is a choice.
  • Move refuses a node without a GPU.
  • If it fails over to a node without a GPU, it doesn't start there until you turn Use the node's GPU off. Edit warns about this when another node has no GPU.

Nodes don't need the same GPU: the container uses whatever GPU the node it runs on has.

Data disks​

A container can have data disks too (⋯ → Edit → Data disks). Each is mounted at a folder inside the container, Mounted at (/mnt/<name> unless you give another, not a system folder such as /etc or /usr), ready to use: no formatting. It is created, grown and removed while the container runs. As for VMs (see Data disks), data disks are replicated, backed up, copied and deleted with the container, but not part of its snapshots.

Shared folders​

A container can use a folder of a NAS share, for example a media library for Jellyfin or documents for Paperless. Add the share once in Settings → Shares; every node mounts it. Then, under the container's ⋯ → Edit → Shared folders, click Add a shared folder and choose the Share, optionally a Folder in it (empty for all of it), where it is Mounted at inside the container, and Read-only if the container should not change it. It changes while the container runs, and follows the container to any node, after a failover too. Removing it only unmounts it: the files stay on the share. VMs mount shares inside the guest instead.

Containers are unprivileged: root inside one is user 1000000 to the NAS, and the container's user 1000 is 1001000.

  • SMB: staxmax mounts the share as the containers' root, writable by every user inside them, so it just works.
  • NFS: the server's permissions apply to those user IDs. Files that everyone may read can be read; to write, either let those user IDs write on the server, or use its option to map all users to one account (all_squash with anonuid; Synology: Squash → Map all users to admin). Files owned by other users appear owned by nobody inside.

While a share is not mounted on a node (the NAS is down), a container there sees an empty folder it cannot write to, so nothing lands on the node's own disk by mistake; the A network share is not mounted alarm says so.

Limits​

  • No live moves. Move to node reads (restart): the container stops, the latest changes are sent, and it starts on the other node, usually within a few seconds. Maintenance mode moves containers the same way.
  • No screen. The console has no Screen tab. The Terminal is the container's own console; press Enter if you see no prompt.
  • No ISO installs, Windows, legacy BIOS, Secure Boot, virtual TPM or memory saving. These belong to virtual hardware, which a container doesn't have, so the dialogs don't offer them.
  • Always unprivileged. Root inside a container is an ordinary user on the node, so a compromised container can't act as root on the node.
  • USB devices only as raw USB. A container gets the USB device itself, while the node keeps driving it. That suits software that talks to the device through libusb, such as a UPS (NUT), a printer or scanner, a security key or an SDR dongle. It doesn't get the sound card, serial port (/dev/ttyUSB0, as on most Zigbee and Z-Wave sticks), disk, camera, Bluetooth or network card the node makes of it: the USB devices dialog warns about these. Pass them through to a VM instead.
  • No Docker inside, for now. Running Docker in a container needs settings staxmax doesn't turn on yet. To run a Docker image, create it as an app; for Docker itself (compose, many images in one place), use a VM.
  • Saved images keep their kind. An image saved from a container makes containers, and one saved from a VM makes VMs.

Containers created outside staxmax​

A container created directly with incus on a node shows up on the Virtual machines page like any other instance, once every node runs a version that supports containers. Like every instance on a node, it is stopped if the node is cut off from the rest of the cluster (see Failover).