Because there is no device called eth0 directly attached to the container.
If you want to modify an inherited device, you must modify it at the source, which in this case would be by editing your default profile.
Though in the case of ipv4.address, that’s obviously not advisable as it would set the same IP for all containers. When using ipv4.address you must add the device directly to the container.
I do have a branch locally which will introduce a new lxc config device override command to do that for you in one step (so copy the device from the profile into the container config directly and then set some key/values).
Thanks, now I see that there are 2 types of devices, inhereted and directly attached.
If lxc config device override command will be required for each container, it will not make big difference, may be only a little bit simplier to remember.
Current way:
lxc launch redis r
lxc network attach lxdbr0 r eth0
lxc config device set r eth0 ipv4.address 10.100.0.100
New command way (if I understood it correctly):
lxc launch redis r
lxc config device override r
lxc config device set r eth0 ipv4.address 10.100.0.100
Maybe it will be better to add new flag to profile which will do the same without any additional commands for each new container?
Yeah, having some way of tagging a device in a profile such that it gets copied to the container’s local config at creation time may be interesting (then again it may make things even more confusing :)).
I suspect ideally we’d want to be able to override individual device properties in the container config, so that you could still inherit all the other properties of your network device from the profile but that makes the entire config resolution and validation a bit of a nightmare which is why we decided not to do so initially.