Setting dns resolv.conf with cloud-init and alpine image?

I have tried various cloud-init configurations, putting things in user-data, network-data. the following network-data section seems to set the ip but NOT the dns name I am NOT using dhcpd, just manual network config and my macvlan doesn’t have dhcp server on the network, I have to set ipv4 manually, and slaac for ipv6.

name: dnsfixed
description: fixedns
devices:
  eth-0:
    network: macvlan
    type: nic
  root:
    path: /
    pool: default
    size: 20GiB
    type: disk
config:
  cloud-init.network-config: |+
    version: 2
    ethernets:
      eth0:
        addresses:
          - 192.168.1.0/24
        gateway4: 192.168.1.10
        nameservers:
          addresses:
            - 192.168.1.1

project: default

I also tried adding the following to MANUALLY create the resolv.conf:

#cloud-config
write_files:
  - path: /etc/resolc.conf
    content: |
      2606:4700:4700::1001
    owner: 'root:root'
    permissions: '0644'

I am using the alpine linux 3.22 cloudinit image, but nothing seems (other than the base networking stuff) seems to work. I put these in the relevant user, network etc. Any ideas?

When you use cloud-init on a container that supports cloud-init, you are making Incus put in the appropriate directory (for cloud-init) in the container the configuration that you have provided earlier in the profile.

That is, you can diagnose all these, and figure out what’s happening when your configuration is running.

The cloud-init logs are in /var/log/cloud-init.log and /var/log/cloud-init-output.log.

The configuration that was found in your Incus profile is placed in /var/lib/cloud/instance/. Check in there to make sure that the formatting is fine, etc.

Alpine uses OpenRC for networking. That means, /etc/network/. Verify that in there you got the configuration that was supplied by the Incus profile.