LXD cheat sheet

 

Container management

Create Ubuntu container lxc launch ubuntu:18.04 my-ubuntu-container
Create Debian container lxc launch images:debian/buster my-debian-container
List containers lxc list
Start container lxc start my-debian-container
Stop container lxc stop my-debian-container
Delete container lxc delete my-debian-container
Edit container config lxc config edit my-debian-container
Add explicit root disk lxc config device add my-debian-container root disk pool=lvm-0 path=/
(pool shoud be the same as in the profile used for creating the container)
Set disk quota lxc config device set my-debian-container root size 20GiB
(does not work with 'dir' storage backend)
Add explicit eth0 lxc config device add my-debian-container eth0 nic name=eth0 nictype=bridged parent=lxdbr0
Assign IP to eth0 lxc config device set my-debian-container eth0 ipv4.address 10.223.91.104
Port forwarding with nat lxc config device add my-debian-container http-proxy proxy listen=tcp:10.1.21.1:80 \
connect=tcp:10.223.91.104:80 nat=true

 

 Storage pool management

 List storage pools lxc storage list
 Create storage pool lxc storage create my-lvm-pool lvm source=/dev/vda
 Delete storage pool lxc storage delete my-lvm-pool
 Move container between pools  lxc stop my-container
lxc move my-container my-container-temp -s target_pool
lxc move my-container-temp my-container

 

Profile management

List profiles  lxc profile list
Create profile  lxc profile create my-profile
Edit profile lxc profile edit my-profile