[lxc-users] Forwarding DNS requests to the host /etc/hosts file
Adil Baig
simplyadilb at gmail.com
Wed May 31 16:34:07 UTC 2017
1. Is very cool! I tried it and it works. I am more interested in 2. as it
seems more future proof when we move away from simple hosts file. Any
suggestions on how to configure an internal dns. Do I need to start another
instance for dnsmasq? Can I reuse the default? How would the container
relay DNS requests to the host?
On Wed, May 31, 2017 at 7:02 PM, Simos Xenitellis <
simos.lists at googlemail.com> wrote:
> On Wed, May 31, 2017 at 1:46 PM, Adil Baig <simplyadilb at gmail.com> wrote:
> > 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.
> >
> > 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?
> >
>
> As far as I understand, you want to get a container to have access to
> the /etc/hosts of its host.
> For this to work, the host needs to make a special arrangement in
> order to make /etc/hosts
> available to the containers.
>
> 1. You might be able to do something like
>
> lxc config device add mycontainer etchosts disk path=/etc/hosts
> source=/etc/hosts
>
> which means that the container's /etc/hosts is actually the host's
> /etc/hosts.
> The LXD containers have a stock /etc/hosts, therefore on their part
> they do not need an individual special entry.
>
> 2. Instead of having these static entries (/etc/hosts), you can
> consider using a local DNS server.
> LXD uses already a separate DNS server (dnsmasq) for the containers,
> which by default resolves all those *.lxd hostnames.
>
> Simos
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170531/c95b149d/attachment.html>
More information about the lxc-users
mailing list