I usually discuss LXD Profiles in relation to network settings. In this tutorial I discuss using profiles for selecting a storage pool, adding limits such as memory/cpu, and adding settings like security.nesting.
You can list out your existing profiles:
lxc profile list
You can edit an existing profile.
lxc profile edit bridgeprofile
To create a profile that does not yet exist:
lxc profile create test
To add a definition to this new profile for your container storage to point to the default storage pool:
lxc profile device add test root disk path=/ pool=default
You can modify the above command accordingly if you have other storage pools. Having a profile that identifies a storage pool eliminates the need to use the default profile.
Assuming that you have the “bridge0” device on your system that we created in the tutorial entitled “LXD Step by Step”, we can add this bridge to our “test” profile:
lxc profile device add test eth0 nic nictype=bridged parent=bridge0
Lets add a memory cap to the test profile:
lxc profile set test limits.memory 4GiB
Add a CPU cap to the test profile:
lxc profile set test limits.cpu 2
Set nesting for all containers created with the “test” profile:
lxc profile set test security.nesting=true
Set “boot.autostart” causing containers created with the “test” profile to be automatically started when the LXD server is booted:
lxc profile set test boot.autostart=true
You can list out the “test” profile to see all the settings we have made thus far:
lxc profile show test
There is no “description” comment for this profile and you can create one with:
lxc profile edit test
Once you complete your changes CTRL O and Enter to Save the file and CTRL X to exit the nano editor.
Now we can see the description with:
lxc profile show test
To create a container using our new profile:
lxc launch ubuntu:22.04 scott-test --profile test
I can see the new container is running on my main LAN with:
lxc list
I can also see and/or modify the “scott-test” container attributes with:
lxc config edit scott-test
So, LXD Profiles can define networks, storage pools, limits and other settings. Using LXD Profiles in this way can help with configuration control of containers that you create.