A common problem:
You can’t resolve the hostname container.lxd (if you have a container named ‘container’) when on the host (using Ubuntu 18.04+).
@simos has proposed a solution in this blog post, however it doesn’t work perfectly in all cases. For example: I think that if lxd is installed with snap, and the host is Ubuntu Desktop, it will not work after a reboot. Or, as was the case on my ubuntu cloud vps, when I applied simos’s proposed solution, I couldn’t resolve any non-lxd names from inside a container anymore. I.e.
host news.com would just fail, from inside the container.
Now I think I found a solution that works in all environments (Desktop, Server, Snap & Apt), which can be applied instead of simos’s blog post:
Step1: create a new file named
/etc/systemd/network/lxd.network with these contents:
[Match] Name=lxdbr0 [Network] DNS=10.121.179.1 Domains=~lxd [Address] Address=10.121.179.1/24 Gateway=10.121.179.1
10.121.179.1 with the address of your lxdbr0 bridge)
Step 2: do this:
sudo systemctl enable systemd-networkd
Step 3: reboot your machine.
@simos, does this seem like a perfectly good solution?