LXD: Create container with profile (connect to VLAN)

create profile

lxc profile copy default mgmt-dev
# lxc profile list
lxc profile device set mgmt-dev eth0 nictype macvlan
lxc profile device set mgmt-dev eth0 parent mgmt-dev-v4432
lxc profile show mgmt-dev

create container with profile

lxc launch ubuntu:18.04 bionic-mgmt-dev -p mgmt-dev
lxc ls

Enable container nesting

lxc config set bionic-mgmt-dev security.nesting true

Configure IP

cat <<EOF> /var/lib/lxd/containers/bionic-mgmt-dev/rootfs/etc/netplan/50-cloud-init.yaml
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses: [10.0.0.123/24]
      gateway4: 10.0.0.254
      nameservers:
        addresses: [10.0.0.253, 10.0.1.253]
        search: [lxd, dev]
EOF

Start container

lxc exec bionic-mgmt-dev bash