Hi,
I want to inject a custom resolv.conf file into the container:
$ lxc profile show rnic2
config: {}
devices:
eth0:
nictype: routed
type: nic
resolvconf:
path: /etc/resolv.conf
readonly: "true"
source: /etc/resolv.conf
type: disk
root:
path: /
pool: default
size: 512GiB
type: disk
shared:
path: /shared
readonly: "true"
source: /shared
type: disk
name: rnic2
used_by:
- /1.0/instances/c100
And container with this doesn’t start.
In case of removing resolvconf section all work as expected.
$ lxc info --show-log c100
Name: c100
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2022/09/07 14:28 EEST
Last Used: 2022/09/07 14:28 EEST
Log:
lxc c100 20220907112823.456 WARN cgfsng - ../src/lxc/cgroups/cgfsng.c:fchowmodat:1252 - No such file or directory - Failed to fchownat(42, memory.oom.group, 65536, 0, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW )
lxc c100 20220907112823.561 ERROR utils - ../src/lxc/utils.c:open_without_symlink:1085 - Too many levels of symbolic links - resolv.conf in /usr/lib/lxc/rootfs/etc/resolv.conf was a symbolic link!
lxc c100 20220907112823.561 ERROR conf - ../src/lxc/conf.c:mount_entry:2410 - Too many levels of symbolic links - Failed to mount "/var/lib/lxd/devices/c100/disk.resolvconf.etc-resolv.conf" on "/usr/lib/lxc/rootfs/etc/resolv.conf"
lxc c100 20220907112823.561 ERROR conf - ../src/lxc/conf.c:lxc_setup:4375 - Failed to setup mount entries
lxc c100 20220907112823.561 ERROR start - ../src/lxc/start.c:do_start:1275 - Failed to setup container "c100"
lxc c100 20220907112823.561 ERROR sync - ../src/lxc/sync.c:sync_wait:34 - An error occurred in another process (expected sequence number 3)
lxc c100 20220907112823.569 WARN network - ../src/lxc/network.c:lxc_delete_network_priv:3631 - Failed to rename interface with index 0 from "eth0" to its initial name "veth71596fcd"
lxc c100 20220907112823.569 ERROR lxccontainer - ../src/lxc/lxccontainer.c:wait_on_daemonized_start:877 - Received container state "ABORTING" instead of "RUNNING"
lxc c100 20220907112823.569 ERROR start - ../src/lxc/start.c:__lxc_start:2074 - Failed to spawn container "c100"
lxc c100 20220907112823.570 WARN start - ../src/lxc/start.c:lxc_abort:1039 - No such process - Failed to send SIGKILL via pidfd 43 for process 27689
lxc 20220907112828.773 ERROR af_unix - ../src/lxc/af_unix.c:lxc_abstract_unix_recv_fds_iov:218 - Connection reset by peer - Failed to receive response
lxc 20220907112828.773 ERROR commands - ../src/lxc/commands.c:lxc_cmd_rsp_recv_fds:127 - Failed to receive file descriptors for command "get_state"
lxc 20220907112828.773 ERROR af_unix - ../src/lxc/af_unix.c:lxc_abstract_unix_recv_fds_iov:218 - Connection reset by peer - Failed to receive response
lxc 20220907112828.773 ERROR commands - ../src/lxc/commands.c:lxc_cmd_rsp_recv_fds:127 - Failed to receive file descriptors for command "get_state"
P.S. I found if I delete resolv.conf file manually m /var/lib/lxd/containers/c100/rootfs/etc/resolv.conf container starts.
Can I overwrite an existing file or maybe there is more correct way to configure DNS in routed network without parent interface?
And does that work? Normally the default DHCP client inside the container will wipe the IP config from eth0 when the container starts? Hence why that article suggests using cloud-init for IP config as well.
What do you you see for ip a and ip r inside the container?
Right, I didn’t realise those posts were associated to this one.
Because systemd-resolved uses a symlink at /etc/resolv.conf to its only dynamically managed file at /run/systemd/resolve/stub-resolv.conf I suggest that as you’re already manually modifiyng the container (by removing the default netplan config) that you also remove /etc/resolv.conf from your container using:
rm /etc/resolv.conf
This should then allow you to add the resolve disk you were originally trying.
If that doesn’t work then you could also try specifying the disk’s source as where the /etc/resolv.conf symlink resolves to on our LXD host.