[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lxc-users
Subject:    Re: [lxc-users] Forwarding DNS requests to the host /etc/hosts file
From:       Simos Xenitellis <simos.lists () googlemail ! com>
Date:       2017-05-31 13:32:26
Message-ID: CAPtVWc4Z5tAeGf9gSuR55Bustu3jD=W8_aQtEgDnJWA-6kRaDA () mail ! gmail ! com
[Download RAW message or body]

On Wed, May 31, 2017 at 1:46 PM, Adil Baig <simplyadilb@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@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic