Map container to hostname

Hello. I have containers 001 and 002. To server is pointed Containers has these ip:
Is bind best way to point to (container 001) and so on or there is easier way that could be done by using lxd rest api?


I suppose you have a single public IP address. If that is indeed the case, then there is not much option in allocating separate public IP addresses per container.
But perhaps you want to do something else?

Yes. I have 1 public ip, and I want to make containers accessible from outside by giving them hostname which is basicaly subdomain of domain pointed to that 1 public ip

In the general case, it is not possible to distinguish between one subdomain from another. Because they both point to the same IP address.

Having said that, if you want to host websites in each container, then it is possible to do so.
It is something called virtual hosts and it uses a feature of the HTTP protocol to direct which hostname it is meant to go to. Also works with https with something called SNI.

If you want to use non-HTTP protocols, then you would need to specify different ports for each service (like with game servers).