Container creation

  1. Create the container from template to have a base platform to build upon:

    lxc-create -B btrfs -n $container_name -t download -- -d Debian -r Stretch -a $(uname -m)

    -B btrfs specifies the backing store's filesystem (btrfs) to enable snapshotting.

    $(uname -m) returns the CPU architecture to automate its selection.

    Using a BTRFS backing store requires the underlying host file-system to be BTRFS formatted as well!

  2. Start the container:

    lxc-start -n $container_name
  3. Update Apt repositories, upgrade all default packages in the container to have an up-to-date system:

    lxc-attach -n $container_name -- sh -c "apt update && apt upgrade -y"
  4. Install dbus within the container to enable easy hostname changes (and optionally rsyslog to enable typical logging):

    lxc-attach -n $container_name -- sh -c "apt install -y dbus rsyslog"
  5. Set hostname according to the container's name for easy recognition / addressing:

    lxc-attach -n $container_name -- hostnamectl set-hostname  $container_name