On a ubuntu 16.04 machine with lxd 2.21, the following code returns all my containers:
from pylxd import Client
client = Client()
client.containers.all()
On a ubuntu 18.04 machine with lxd 3.0.1, the same code returns an empty list
On both machines, the command lxc list
returns many containers,
for some reason the client connection on the newer lxd host is not "seeing" the containers.
The solution was to set this environment variable:
The api uses the socket
/var/snap/lxd/common/lxd/unix.socket
by default, and in my installation the proper socket to use is/var/lib/lxd/unix.socket