Accessing host ip by name


host got a:

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

I can ping 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,


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?


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,


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

See for how it works in docker.

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