LXD on Debian Sid

Tuesday April 4, 2017

Constrained by the “1 container 1 process” philosophy on using Docker containers plus the hard problem on trying to get the init to work on containers without pulling teeth (except for Upstart), I knew that I had to try LXD as the alternative. Brief introduction: LXD is a project by Canonical to extend the capability of LXC (Linux Containers), which what the Docker previously depended on. LXC is still the main interface client but now it functions with LXD as its background, system-wide daemon. It works like a container but you can treat it like a VM.

Official lxd package is still in progress on Debian (even in Sid as of writing). For Debian users to test it, it is available as a Snap package. So first, let’s install the snapd package manager to access the Snap Store. More information is available on the Snapcraft website.

sudo apt-get install snapd
sudo snap install core
sudo snap install lxd

At first I installed lxd without installing core, I bumped into a problem where my terminal returned [/] Run configure hook of "core" snap if present indefinitely. That’s why the package core must be installed first. After installing the lxd, a new group called lxd is automatically created. Only user(s) in lxd group can use the lxd and lxc commands. Let’s add our $USER into the lxd group.

sudo addgroup $USER lxd
newgrp lxd

System restart is required to activate the new group membership but here we have the command newgrp that can activate the membership without a system restart. So now we have our $USER ready to run the lxd but is unlikely our $USER here can find the lxd binary. Hence, let’s update our PATH. I use zsh as my shell because I like it better than the regular bash. In my ~/.zshrc I now have this:

vim ~/.zshrc
>> export PATH="/snap/bin:$PATH"

# close the file, reload .zshrc
source ~/.zshrc

Our $USER now should be ready to invoke the lxd command. Start with lxd init to configure the daemon. I will update this soon with more information on configuring the daemon and how to use the lxc client interface.