Setting resource limits on LXD containers
In this recipe, we will learn to set resource limits on containers. LXD uses the cgroups feature in the Linux kernel to manage resource allocation and limits. Limits can be applied to a single container through configuration or set in a profile, applying limits to a group of containers at once. Limits can be dynamically updated even when the container is running.
How to do it…
We will create a new profile and configure various resource limits in it. Once the profile is ready, we can use it with any number of containers. Follow these steps:
Create a new profile with the following command:
$ lxc profile create cookbook Profile cookbook created
Next, edit the profile with
lxc profile edit
. This will open a text editor with a default profile structure in YML format:$ lxc profile edit cookbook
Add the following details to the profile. Feel free to select any parameters and change their values as required:
name: cookbook config: boot.autostart: "true"...