[lxc-users] Forwarding DNS requests to the host /etc/hosts file

Andrey Repin anrdaemon at yandex.ru
Wed May 31 20:21:57 UTC 2017

Greetings, Adil Baig!

> I have several containers running on host machines. The host machine is
> part of a LAN network. Each host has an update /etc/hosts file with domain names to other LAN entities.

I strongly suggest you raise local DNS server.
LXC already have a dependency on dnsmasq, you can easily configure it for
fakeresolve in addition to LXC-specific setup.

> My problem is I cannot use the hostnames defined on the host inside the
> container (without actually copying the /etc/hosts file in). I'd rather not
> copy the file as I sync /etc/hosts file using Ansible, and the Ansible
> inventory cannot manage LXD containers dynamically.

> How is it possible to set up the containers so they look up entries in the
> host machines' /etc/hosts file?

My strong opinion is that /etc/hosts is a crutch from 1960's and should not be
used, there's always a better option.

With best regards,
Andrey Repin
Wednesday, May 31, 2017 23:20:01

Sorry for my terrible english...

More information about the lxc-users mailing list