Making an application aware of locality

I’m curious if there are any mechanisms available from within the LXD containers, which reveal the underlying host on which the container is running?

Specifically, I’m asking because I’m trying to simulate a number of hosts with LXD (let’s arbitrarily say 4 hosts), and would ideally like to run {2..n} docker containers inside the LXD containers.

My intention has been to build baremetal >> LXD >> docker >> kubernetes >> rancher

Then, I’d rely on rancher metadata to determine the locality of the docker container pods.

So, my more tl;dr version is – within LXD containers, is there any mechanism to provide metadata about the host on which the container is run?

Please forgive me if I missed something in the documentation.

LXD doesn’t expose that information as we’d consider this an information leak.

But you can certainly set this up yourself with:

lxc profile set default user.host $(hostname)

At which point you’d be able to query this from within the container with:

curl --unix-socket /dev/lxd/sock lxd/1.0/config/user.host
2 Likes

Stephan,

Thanks for the quick response! That’ll be perfect for my use case.

  • Andrew