API: lookup of container IPs

The output of ‘lxc ls’ returns IPV4 and IPV6 if assigned to a listed container.

When doing a lookup by the LXD API with
I would have expected to get ipv4/ipv6 returned as well. But I don’t find these values (and I didn’t find them searching the API source code).

Did I miss s.th. or is this an issue of a new feature request?


If you want to compare the lxc commands with your use of the REST API, you can run in a separate window the following,

lxc monitor --pretty --type=logging --loglevel=debug

This will show how lxc commands as you run them and you can compare with what you are trying to do with the API over the network.

lxc list performs a

DBUG[12-21|18:30:10] handling      ip=@ method=GET url="/1.0/containers?recursion=2"

If you are not performing a recursion, then you need to use https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersnamestate instead. For example,

curl -G -s --unix-socket /var/snap/lxd/common/lxd/unix.socket a/1.0/containers/mycontainer/state | jq .

Note that lxc query /1.0/containers/mycontainer/state may be an easier way to get to the same data (bit shorter than curl)

1 Like