Skip to content
Operating the daemon

Operating the daemon

dicerd runs as a systemd service, dicerd.service, which the dicer package or install.sh sets up. This guide covers running it day to day: changing its configuration, restarting and upgrading it without disturbing guests, backing it up, and removing it.

The service

$ sudo systemctl status dicerd
$ journalctl -u dicerd -f

The service starts at boot, and systemd restarts it if it fails.

Restarting is safe

Each guest runs in a hypervisor process of its own, which outlives the daemon. Stopping or restarting dicerd leaves every guest running, and the next daemon to start adopts them as they are:

State when the daemon stoppedWhat the next daemon does
Running or paused, and still isAdopts it as it is.
Running or paused, but it ended while the daemon was downHandles it like any instance that ends: its restart policy applies.
Starting or stoppingEnds its hypervisor and marks it Failed, since it cannot finish what the old daemon was doing.
RestartingRestarts it when the rest of its wait is over.
StandbyLeaves it on standby.

While the daemon is down, guests keep running and their published ports keep working, but nothing manages them. There are no restarts, no health checks, no automatic standby and no API. An instance on standby cannot be woken by a connection either, because the daemon is what listens on its ports.

When the daemon is stopped, it waits up to 10 seconds for calls in flight, such as dicer logs -f and dicer exec sessions, and then ends them.

Changing the configuration

The daemon reads its configuration, /etc/dicerd/config.yaml, when it starts. Every setting is described in the configuration reference. Change the file, check it, then restart the daemon:

$ sudoedit /etc/dicerd/config.yaml
$ sudo dicerd validate
/etc/dicerd/config.yaml is valid.
$ sudo systemctl restart dicerd

dicerd validate checks the file as the daemon does when it starts. It checks that every key and value is valid, that the TLS files and registry credentials it names can be read, and that this host can give instances the resources it allows. A problem is reported with its line number:

$ sudo dicerd validate
Error: parse /etc/dicerd/config.yaml: yaml: unmarshal errors:
  line 12: field log_lvl not found in type daemon.Config

The daemon does not start with a configuration it cannot use, and its log says why. Guests keep running in the meantime. Fix the file and start the daemon again.

The certificate and key of server.crt_file and server.key_file are the one exception to the restart rule. The daemon reloads them when the files change, so renewing them needs no restart. Tokens need no restart either: one works as soon as dicer token create makes it, and stops as soon as it is deleted.

If you move data_dir, the packaged service cannot write to the new directory until you allow it in a drop-in:

/etc/systemd/system/dicerd.service.d/data-dir.conf
[Service]
ReadWritePaths=/srv/dicer

Upgrading

Upgrade Dicer the same way you installed it:

$ sudo apt update
$ sudo apt install dicer

If you changed the configuration, dpkg asks which version to keep.

The new daemon adopts the running guests. An upgrade replaces the service file, so put any changes of your own to it in a drop-in under /etc/systemd/system/dicerd.service.d/.

Running guests keep the hypervisor, dicer-init and agent they booted with. An instance gets the new ones the next time it boots. dicer version shows the version of both the client and the daemon.

A release can drop an old hypervisor version. Instances on standby and memory snapshots that still use it can then no longer be resumed. Read Before a version is removed before you upgrade.

Starting the daemon also starts every stopped instance whose restart policy is always, and every one with unless-stopped that you did not stop yourself. An upgrade can therefore start instances.

When the host reboots

A reboot ends every running guest. When the daemon starts again, those instances are stopped, and the ones whose restart policy is always or unless-stopped are started. Give that policy to instances that should come back with the host.

An instance on standby is frozen to disk, so it is still on standby after the reboot. Its restart policy does not start it, and dicer start resumes it where it was.

To shut the host down cleanly, stop the instances first, so their workloads can shut down as they expect:

$ dicer stop $(dicer ps -q --filter state=running)

Backing up

Dicer keeps everything in two places: its configuration in /etc/dicerd, and its state in /var/lib/dicer. See Files and environment for what is where.

The state directory holds overlay disks, volumes and snapshots, which are sparse files. Copy them in a way that keeps them sparse, or the copy takes their full size. A disk copied while its guest runs is only as consistent as one after a power cut. For a copy you can rely on, stop the instances first:

$ dicer stop $(dicer ps -q --filter state=running)
$ sudo systemctl stop dicerd
$ sudo tar --sparse -czf dicer-backup.tar.gz /etc/dicerd /var/lib/dicer
$ sudo systemctl start dicerd

You can leave out the images and the layer cache, /var/lib/dicer/images and /var/lib/dicer/oci-cache, because the daemon pulls again what it needs. It pulls each instance’s image by its digest, so the instance boots the same image as before, as long as the registry still has it.

To restore, stop the daemon, put both directories back where they were, and start it. Instances come back stopped, apart from those their restart policy starts.

Uninstalling

Delete the instances first. Removing Dicer stops the daemon, and any guest still running then keeps running, unmanaged, with its bridge and firewall rules left behind:

$ dicer rm -f $(dicer ps -q)

Then remove Dicer the same way you installed it:

$ sudo apt purge dicer

This removes the binaries, the service and /etc/dicerd, including any TLS certificates kept there. apt remove keeps /etc/dicerd.

Otherwise /var/lib/dicer is kept, with every image, overlay disk, volume and snapshot in it. To remove it too, which cannot be undone:

$ sudo rm -rf /var/lib/dicer

Removing a package leaves the networks’ bridges in place until the host reboots. The script leaves only a bridge that a guest is still attached to. Each is named dicer-NAME after its network, or dbr- and a hash when the name is too long. Remove them before you install Dicer again without /var/lib/dicer. A new daemon cannot create a network on a subnet that a leftover bridge still holds, and that includes its default network. To remove one, run sudo ip link delete dicer-NAME.