My homeassistant OCI is running fine with host networking (raw.lxc=“lxc.net.0.type=none”) but when I try to map host file /run/systemd/resolve/stub-resolv.conf into the container as /etc/resolv.conf in read-only ro mode, the container somehow manages to overwrite the mapped file.
I can see the mountpoint inside the container even after the overwrite, and if I mount it under /tmp/resolv.conf instead then it looks as it should, but I need it under /etc/resolv.conf. I’m thinking that allowing this to be overwritten may be a bug in Incus? Isn’t ro file mapping made for exactly for this scenario? I’m hesitant to open a bug report before running it by the community.
HERE IS MY ACTUAL USE-CASE:
The container uses host networking so let’s inspcect split DNS on the host:
$ resolvectl status br1 incusbr0
Link 4 (br1)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.0.1
DNS Servers: 192.168.0.1 fd01:7439:2568::1
DNS Domain: private.lan
Default Route: yes
Link 5 (incusbr0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.210.158.1
DNS Servers: 10.210.158.1
DNS Domain: incus
Default Route: yes
The above DNS servers are consolidated by systemd-resolved split DNS like so:
$ cat /etc/resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search incus private.lan
But OCI container homeassistant ignorantly requests its own DNS address for the host’s interface, and unfortunately OpenWrt complies, thereby gutting split DNS with this nonsense inside the container:
$ incus exec homeassistant -- cat /etc/resolv.conf
nameserver 192.168.0.1
domain private.lan
So I desperately try to restore proper operation by mapping resolv.conf from the host into the container:
$ incus config device add homeassistant resolvconf disk source=/run/systemd/resolve/stub-resolv.conf path=/etc/resolv.conf readonly=true
But in spite of the above being mapped in as ReAd OnLy, the container fiendishly manages to overwrite it with the hapless DNS option it misappropriated via its rogue DHCP request, thereby instantly ruining split DNS name resolution inside the container and rendering my life entirely worthless. This would all be oh-so-simple if I just had the bigger hammer that ro might have been…
P.S. I created the container like this:
$ incus create ghcr:home-assistant/home-assistant:stable homeassistant \
--no-profiles \
--storage default \
-c raw.lxc="lxc.net.0.type=none" \
-c security.privileged=true \
-c boot.autostart=true \
-c boot.autorestart=true \
-c environment.TZ=America/Vancouver
$ incus config device add homeassistant dbus disk source=/run/dbus path=/run/dbus readonly=true
$ incus storage volume create default ha_config
$ incus storage volume set default ha_config security.shifted=true
$ incus storage volume attach default ha_config homeassistant /config