Bare metal context: Ubuntu 22.02.2 running latest/stable snap lxd.
The default profile networking is set to NIC-bound br0 bridge with no local bridge enabled.
lxc init ubuntu:22.04 digital-archives
After spinning up this container, I created a /etc/netplan/10-lxc.yaml file configured with a static IP address and moved 50-cloud-init.yaml to 50-cloud-init.yaml-ORIG so it wouldn’t execute and ran
netplan apply
However, see below:
archives@www2:~$ lxc list
+------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------------+---------+---------------------+------+-----------+-----------+
| digital-archives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
+------------------+---------+---------------------+------+-----------+-----------+
archives@www2:~$ lxc stop digital-archives
archives@www2:~$ lxc list
+------------------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------------+---------+------+------+-----------+-----------+
| digital-archives | STOPPED | | | CONTAINER | 0 |
+------------------+---------+------+------+-----------+-----------+
archives@www2:~$ lxc move digital-archives digitalarchives
archives@www2:~$ lxc list
+-----------------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------------+---------+------+------+-----------+-----------+
| digitalarchives | STOPPED | | | CONTAINER | 0 |
+-----------------+---------+------+------+-----------+-----------+
archives@www2:~$ lxc start digitalarchives
archives@www2:~$ lxc list
+-----------------+---------+----------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------------+---------+----------------------+------+-----------+-----------+
| digitalarchives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
| | | 172.18.90.227 (eth0) | | | |
+-----------------+---------+----------------------+------+-----------+-----------+
On further examination, the 50-cloud-init.yaml netplan was magically recreated:
root@digital-archives:~# ls /etc/netplan
10-lxc.yaml 50-cloud-init.yaml 50-cloud-init.yaml-ORIG
Any idea why this happened?
I changed the name of the container back to the original name, removed /etc/netplan/50-cloud-init.yaml and now the behavior doesn’t repeat:
archives@www2:~$ lxc list
+------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------------+---------+---------------------+------+-----------+-----------+
| digital-archives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
+------------------+---------+---------------------+------+-----------+-----------+
archives@www2:~$ lxc stop digital-archives
archives@www2:~$ lxc start digital-archives
archives@www2:~$ lxc list
+------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------------+---------+---------------------+------+-----------+-----------+
| digital-archives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
+------------------+---------+---------------------+------+-----------+-----------+
Just a little bit of additional testing shows that the creation of /etc/netplan/50-cloud-init.yaml is triggered by changing the name of the container. Repeating my previous steps:
archives@www2:~$ lxc list
+------------------+---------+---------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------------+---------+---------------------+------+-----------+-----------+
| digital-archives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
+------------------+---------+---------------------+------+-----------+-----------+
archives@www2:~$ lxc stop digital-archives
archives@www2:~$ lxc move digital-archives digitalarchives
archives@www2:~$ lxc list
+-----------------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------------+---------+------+------+-----------+-----------+
| digitalarchives | STOPPED | | | CONTAINER | 0 |
+-----------------+---------+------+------+-----------+-----------+
archives@www2:~$ lxc start digitalarchives
archives@www2:~$ lxc list
+-----------------+---------+----------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-----------------+---------+----------------------+------+-----------+-----------+
| digitalarchives | RUNNING | 172.18.90.42 (eth0) | | CONTAINER | 0 |
| | | 172.18.90.227 (eth0) | | | |
+-----------------+---------+----------------------+------+-----------+-----------+
I’m going to call this a bug rather than a feature.