Accessing host ip by name

Hi,

host got a:

lxdbr0 Link encap:Ethernet HWaddr fe:f7:d0:b1:6b:b9
inet addr:10.60.117.1 Bcast:0.0.0.0 Mask:255.255.255.0

I can ping 10.60.117.1 from LXD container, but is there a way to know what IP to ping from inside the container without doing an ifconfig in the host first? Thanks,

SQ

The container has a hostname, like mycontainer.lxd, and is accessible from within any container (but not the host, but default).

The IP address you are looking for, is the IP address of the gateway. It does not get a hostname by default and I believe that if there is need, it should be possible to configure LXD’s dnsmasq to produce something.

In most cases, you would rather not get the containers to contact a service in the host, but put all services in containers. Do you have a use-case that would require the containers to contact the host?

Hi,

I was trying to run docker inside a lxd container, it works, but too slow, so I am thinking of just run some apps under docker in the host, and let lxd container access host for some docker apps,

Thanks,

Could it be possible to have similar behaviour to that of docker by using a special DNS name such as host.lxd.internal?

See https://docs.docker.com/docker-for-windows/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host for how it works in docker.

if you are using the standard lxdbr0 bridge, it’s available under the _gateway name.