In the last step we created a new isolated project and then tried to create a new container inside it. Unfortunately we were unable to because we got a No root device could be found
error. This is because the default profile within the new project has not been configured yet.
Lets do so now…
Comparing profiles
First, we can compare the default
profile from our default
project:
lxc profile show default --project default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/containers/tutorials
- /1.0/containers/webserver?project=client-website
- /1.0/containers/dbserver?project=client-website
- /1.0/containers/webserver
With the default
profile in the client2-website
project:
lxc profile show default --project client2-website
config: {}
description: Default LXD profile for project client2-website
devices: {}
name: default
used_by: []
We can see that the missing configuration is for the devices
section, specifically the nic
and disk
devices.
Creating the disk device
Lets add a root
disk device sharing the global default
storage pool:
lxc profile device add default root disk path=/ pool=default --project client2-website
Creating the nic device
Next we add an eth0
nic device to the default profile:
lxc profile device add default eth0 nic name=eth0 nictype=p2p --project client2-website
Note: We have changed the networking config for this nic device to be p2p rather than bridge to demonstrate the ability to have different default
profiles in separate projects.
Create the containers
Now lets try again to create the containers for this project:
lxc launch ubuntu:18.04 webserver --project client2-website
lxc launch ubuntu:18.04 dbserver --project client2-website
And check they are created:
lxc ls --project client2-website
+-----------+---------+------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------+---------+------+------+------------+-----------+
| dbserver | RUNNING | | | PERSISTENT | |
+-----------+---------+------+------+------------+-----------+
| webserver | RUNNING | | | PERSISTENT | |
+-----------+---------+------+------+------------+-----------+