Location of containers?

I am reading a book about linux and lxd containers and the author says :

David Clinton: On my system, LXD - even a snap-installed LXD - will create the containers in the /var/lib/lxd/containers/ directory.

yet I have lxd installed with snap and it is as if there are no containers on my system ???

sherab@Sherab-PureOS:~$ cd /var/lib/
sherab@Sherab-PureOS:/var/lib$ ls lxd
ls: cannot access 'lxd': No such file or directory

So I have this /var/snap/lxd

root@Sherab-PureOS:/var/snap/lxd/common/lxd/containers# ls
gui1604  gui1804  ubu18-test

The containers name are bold red color with a background [black]
Doing ls -l on a container name

root@Sherab-PureOS:/var/snap/lxd/common/lxd/containers# ls -l gui1804

lrwxrwxrwx 1 root root 65 Apr 22 17:57 gui1804 -> /var/snap/lxd/common/lxd/storage-pools/default/containers/gui1804

follow the link

    root@Sherab-PureOS:/var/snap/lxd/common/lxd/containers# cd /var/snap/lxd/common/lxd/storage-pools/default/containers/
    bash: cd: /var/snap/lxd/common/lxd/storage-pools/default/containers/: No such file or directory

So where are the containers located?

the containers are loaded in the lxd daemon’s namespace, you have to borrow the namespace from it; try

sudo nsenter -t $(pgrep daemon.start) -m – ls /var/snap/lxd/common/lxd/storage-pools/default

nsenter: failed to execute –: No such file or directory


NSENTER(1) User Commands NSENTER(1)

nsenter - run program with namespaces of other processes

package: utils-linux for ubuntu (probably debian too). No idea for your particular distro.

Thank you