This guide covers how to recover Containarium and all containers after the jump server instance is recreated (e.g., after spot instance termination or system failure).
When using persistent storage (ZFS on external disk), your containers survive instance recreation. The containarium recover command automates the full recovery process.
- External disk with ZFS storage pool attached and mounted
- Containarium binary installed at
/usr/local/bin/containarium - Incus installed and running
If a recovery config exists on the persistent storage:
# Auto-detect config from persistent storage
sudo containarium recover
# Or explicitly specify config file
sudo containarium recover --config /mnt/incus-data/containarium-recovery.yamlIf no config file exists, specify parameters explicitly:
sudo containarium recover \
--network-name incusbr0 \
--network-cidr 10.0.3.1/24 \
--storage-pool default \
--storage-driver zfs \
--zfs-source incus-pool/containersPreview what would be done without making changes:
sudo containarium recover --config /mnt/incus-data/containarium-recovery.yaml --dry-runThe containarium recover command performs these steps automatically:
Creates the incusbr0 network bridge with the configured CIDR:
incus network create incusbr0 ipv4.address=10.0.3.1/24 ipv4.nat=true ipv6.address=noneImports the existing ZFS storage pool and recovers container definitions:
incus admin recover
# Answers: yes, default, zfs, incus-pool/containers, (empty), no, yes, yesAdds the network device to the default profile:
incus profile device add default eth0 nic network=incusbr0 name=eth0Starts all recovered containers:
incus start --allRestores jump server SSH accounts from container public keys:
containarium sync-accountsThe daemon automatically saves a recovery config to persistent storage during startup. This file contains all parameters needed for recovery:
Location: /mnt/incus-data/containarium-recovery.yaml
Example contents:
network_name: incusbr0
network_cidr: 10.0.3.1/24
storage_pool_name: default
storage_driver: zfs
zfs_source: incus-pool/containers
daemon:
address: 0.0.0.0
port: 50051
http_port: 8080
base_domain: <your-base-domain>
caddy_admin_url: http://localhost:2019
jwt_secret_file: /etc/containarium/jwt.secret
app_hosting: true
skip_infra_init: trueAfter running containarium recover, complete the setup:
sudo mkdir -p /etc/containarium
sudo openssl rand -hex 32 | sudo tee /etc/containarium/jwt.secret > /dev/null
sudo chmod 600 /etc/containarium/jwt.secretsudo tee /etc/systemd/system/containarium.service > /dev/null << 'SERVICE'
[Unit]
Description=Containarium Container Management Daemon
Documentation=https://github.com/footprintai/Containarium
After=network.target incus.service
[Service]
Type=simple
ExecStart=/usr/local/bin/containarium daemon --address 0.0.0.0 --rest --http-port 8080 --jwt-secret-file /etc/containarium/jwt.secret --app-hosting --base-domain <your-base-domain> --caddy-admin-url http://localhost:2019 --skip-infra-init
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
SERVICE
sudo systemctl daemon-reload
sudo systemctl enable containarium
sudo systemctl start containariumsudo containarium token generate \
--username admin \
--roles admin \
--expiry 720h \
--secret-file /etc/containarium/jwt.secretsudo incus exec containarium-core-caddy -- caddy reload --config /etc/caddy/CaddyfileThe storage pool is already imported. Use --skip-infra-init flag or check:
incus storage listThe network is already created. Check:
incus network listThe default profile may be missing the eth0 device:
# Check profile
incus profile show default
# Add eth0 if missing
incus profile device add default eth0 nic network=incusbr0 name=eth0
# Restart containers to pick up the change
incus restart --allRun the sync-accounts command:
sudo containarium sync-accounts -v-
Store recovery config on persistent disk: The daemon auto-saves to
/mnt/incus-data/containarium-recovery.yaml -
Use ZFS for container storage: ZFS datasets survive instance recreation when on persistent disk
-
Keep JWT secret on persistent storage: Store
/etc/containarium/jwt.secreton persistent disk or use a secrets manager -
Regular backups: Even with persistent storage, maintain regular backups of container data
-
Test recovery procedure: Periodically test the recovery process to ensure it works