LXD on Alpine

By CK. Date: . Last updated: .

System

apk update
apk add lxd lxd-client lxcfs dbus

LXD will create /var/lib/lxd/unix.socket with owner root and group root.

Change to group lxd, so that any user in that group can use it.

# /etc/conf.d/lxd
LXD_OPTIONS=" --group lxd"

And add my user to that group.

addgroup ck lxd

Prevent issues with e.g. "too many open files".

$ cat /etc/sysctl.conf
# content of this file will override /etc/sysctl.d/*
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10

fs.inotify.max_queued_events = 1048576
fs.inotify.max_user_instances = 1048576
fs.inotify.max_user_watches = 1048576
kernel.keys.maxkeys=50000

ZFS

apk add zfs zfs-lts
reboot
modprobe zfs

Misc

Taken from https://wiki.alpinelinux.org/wiki/LXD

echo "session optional pam_cgfs.so -c freezer,memory,name=systemd,unified" >> /etc/pam.d/system-login
echo "lxc.idmap = u 0 100000 65536" >> /etc/lxc/default.conf
echo "lxc.idmap = g 0 100000 65536" >> /etc/lxc/default.conf
echo "root:100000:65536" >> /etc/subuid
echo "root:100000:65536" >> /etc/subgid

Autostarts

rc-update add lxc
rc-update add lxd
rc-update add lxcfs

LXD should be running. Next: LXD Init


LXD

See also