How to list all containers on every connected LXD server

I have a custom built global management server that can manage any number of LXD servers at any given time, and my code currently loops through each server in it’s database to list statistics. I know that you are able to quickly list all containers on the current server by running:
lxc list
and that you are also able to list all containers on a remote server by running:
lxc list <remote>:

Is there a way to list all containers on all servers (including the current one and any connected ones) in one command, something like:
lxc list *
or
lxc list *:
(neither of these work by the way)

Nope. You can obviously script your way around this using lxc remote list and then hitting lxc list for each of them, but note that this may get quite expensive on the servers if you keep running that.

This is a bit of an unusual use case so we’re unlikely to make changes to LXD to make it easier, though you can certainly script your way around this or even write your own small LXD API client to do this.

1 Like

Thanks! I assumed this was the case and I’m doing something similar to your first suggestion. Luckily the most taxing stats are only pulled when a user loads a certain page on our management server. If it were a live updated dashboard I’d consider writing an API but this works for my current setup. It was really more of a nice-to-have than a need but it’s good to know.