[lxc-users] Container to container comms by hostname

Jamie Brown Jamie.Brown at mpec.co.uk
Fri Mar 11 15:11:24 UTC 2016


I’m not entirely sure, but this may have something to do with /var/lib/misc/dnsmasq.lxcbr0.leases .

Having deleted and re-created the container again, I have noticed that the host name is not listed in the above file and I get the following;

lxc exec container2 -- nslookup container1
Server:      10.0.3.1
Address:    10.0.3.1#53

** server can’t find container1: NXDOMAIN

Should LXD be updating this cache when containers are stopped/started? It is currently full of entries for other containers, but is missing the one that was recently dropped/created. I imagine if I wait a while it will appear.

From: Jamie Brown <Jamie.Brown at mpec.co.uk<mailto:Jamie.Brown at mpec.co.uk>>
Date: Friday, 11 March 2016 at 13:56
To: LXC users mailing-list <lxc-users at lists.linuxcontainers.org<mailto:lxc-users at lists.linuxcontainers.org>>
Subject: Re: Container to container comms by hostname

Update: After about 5 minutes the hostname suddenly became available to ping from the other containers.

I guess this is just some sort of DNS caching issue?

Would still be interested in understanding how people are achieving this.

From: Jamie Brown <Jamie.Brown at mpec.co.uk<mailto:Jamie.Brown at mpec.co.uk>>
Date: Friday, 11 March 2016 at 13:51
To: LXC users mailing-list <lxc-users at lists.linuxcontainers.org<mailto:lxc-users at lists.linuxcontainers.org>>
Subject: Container to container comms by hostname

Hi,

I’m using the default network configuration from LXD with lxcbr0 and 10.0.3.* IP range.

If I create multiple containers (ubuntu:14.04) then I am able to contact these containers from within each other by hostname.

e.g.
container1
container2
container3

Within container2 I can simply run ‘ping container1’ and it manages to resolve the IP without any further configuration.

However, if I then delete container1 and re-create it, the IP address of container1 may change (via DHCP) and when I try to ping container1 from container2 I simply receive “ping: unknown host container1”.

I’m not sure what the intended behaviour is here, I was really happy when I realised I could simple communicate between containers by container name (host name), but now I’m not so sure it is a reliable method.

Could someone outline the intended behaviour here, and perhaps recommend a more reliable way of container to container communication without relying on knowing the IP addresses?

Thanks,

Jamie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20160311/ed12ff62/attachment.html>


More information about the lxc-users mailing list