Environment
Host is Ubuntu 22.04.2 LTS
I have 2 sets of containers
- Ubuntu 16.04.7 LTS containers which work fine
- Ubuntu 22.04.2 LTS which I’m testing currently as I want to upgrade all containers eventually
$ apt list -i | grep lxc
liblxc-common/jammy,now 1:5.0.0~git2209-g5a7b9ce67-0ubuntu1 amd64 [installed,automatic]
liblxc1/jammy,now 1:5.0.0~git2209-g5a7b9ce67-0ubuntu1 amd64 [installed,automatic]
lxc-templates/jammy,now 3.0.4-5 amd64 [installed]
lxc-utils/jammy,now 1:5.0.0~git2209-g5a7b9ce67-0ubuntu1 amd64 [installed,automatic]
lxc/jammy,jammy,now 1:5.0.0~git2209-g5a7b9ce67-0ubuntu1 all [installed]
lxcfs/jammy,now 5.0.0-0ubuntu2 amd64 [installed,automatic]
$ apt list -i | grep dnsmasq
dnsmasq-base/jammy-updates,jammy-security,now 2.86-1.1ubuntu0.1 amd64 [installed,automatic]
Container creation
- Created both the 16 and 22 containers in the same way, replacing the release name
lxc-create --template download --name {name} --logfile {log} -l trace -- --dist ubuntu --release {release} --arch amd64
-
Also, I manually add each container’s IP in the host’s
/etc/hosts
file -
“resetting dnsmasq cache”
sudo pkill -1 -u lxc-dnsmasq
Issue
The issue is my /etc/resolv.conf
file.
In my Ubuntu 16 containers, this had one simple line
nameserver 10.0.3.1
In my Ubuntu 22 containers, this contains
nameserver 127.0.0.53
options edns0 trust-ad
search .
My Ubuntu 16 containers can ping each other just fine. My Ubuntu 22 containers cannot. They also can’t ping the host by its name, which the Ubuntu 16 containers can
myuname@mycontainer-local:~$ sudo ping -v rabbitmq-local
ping: rabbitmq-local: Temporary failure in name resolution
(yes, I strangely need sudo on the 22 containers, otherwise it complains it’s not allowed to open a socket)
The thing is, I never configured /etc/resolv.conf
or anything that would generate it on my Ubuntu 16 containers. So I have no clue how it knew that it should use 10.0.3.1
, but on Ubuntu 22 it clearly doesn’t. Editing the /etc/resolv.conf
on Ubuntu 22 to match the old file from Ubuntu 16, fixes the issue. But obviously this file is automatically generated, so this is only a temporary workaround. What is a more permanent solution?
I looked into potentially editing /etc/netplan/10-lxc.yaml
but
- I’m not 100% clear on what to edit
- I’m not sure if it’s possible to get it working without manually adding 10.0.3.1 to the file. Something was configuring it automatically on Ubuntu 16 and I’d like to keep doing it automatically instead of just hard coding this IP in a conf file somewhere (though if there’s no other option, I guess I’ll go with that)