I’m creating a container via the LXD api and setting the cloud-init options via user.network-config:
The works and the container picks up the static ip / dns settings specified. However the container also picks up a DHCP IP from my router. I’ve narrowed it down to 10-lxc.yaml which sets dhcp4: true.
If I set 10-lxc.yaml explicitly to false or remove the file, the expected behavior of getting only the static ip works.
Is this file supposed to be removed somehow or how is it also applying cloud-init settings if 50-cloud-init.yaml is being processed? Is it supposed to be ignored?
Container is running Ubuntu 18.04.3 LTS with cloud-init.
I copied it to my local install via lxc image copy images:<finger print> local: --alias=<myalias> a while back (back in January I believe). I can’t seem to find the original image I copied it from based on the fingerprint unfortunately.
My containers are being spun up by the local copy.
Side note: I initially set the contents of 10-lxc.yaml to be blank or just a comment, but that causes cloud-init to not setup the static IP in 50-cloud-init.yaml for some reason. Tried grep’ing the cloud-init.log / cloud-init-output.log to see why, but nothing stuck out (also not super familiar with the cloud-init process to be honest).
Regardless, my temp fix above works for now, thanks!
Great post @Noah, thanks! Really helped ALOT on an issue with Orabuntu-LXC.
FWIW there is a way to override the “dhcp4: true” setting in 10-lxc.yaml (although I can’t image a use case). This was the band-aid I had been using until I saw this thread. So the band-aid was to put this entry in the dhcpd.conf file for the isc-dhcp-server service: