No swap inside containers when using snap LXD

This is a known issue.

Until it is fixed, the workaround would be:

1 - Enable swap accounting. Add boot argument swapaccount=1 to the GRUB_CMDLINE_LINUX_DEFAULT= variable in /etc/default/grub, then run ‘update-grub’ as root and reboot;

2 - Use lxc config set containername ...

  • limits.memory must be set to some value (percentage or fixed value)
  • limits.memory.enforce must be set to hard
  • limits.memory.swap must be set to false

More info here.