Disclose container data folder files under LXD host machine

Hi !

I was wondering how could I get access to my container data or log files ?
My current situation is next,

ls -al /mnt/mtLXCdatadir/containers/DatabaseContainerName/rootfs/var/lib/pgsql/10/ and after 10 I see empty folder. But in real case when in exec into container there are database data files + logs. Im more interested of pgsql logs. Is it due to the fact that data folder is hosted by different storage LUN or is it some kind of LXC permissions what prevents me to open up data folder under host machine ?

Since im running elastic stack and I would like to enable my host machine filebeat container collect my containers data but for that I need to see data dir content. Alternative method is to instsall and setup filebeat into each lxc container im running but I would keep it as simple as possible and setup only one filebeat agent what can collect LXC container data from source host machine.

Best,

You can’t see it because the data isn’t at that path, it’s on some other filesystem which is mounted on that directory in the container and mounts don’t propagate back to the host.

One trick which works pretty well is to use /proc/<PID>/root/ to access the view of the filesystem from the container’s point of view, replacing PID by the host PID of any process that’s running inside the container.

If your container is unprivileged, you do need to be careful about uid/gid of the various files as a file written by root from the host may end up completely unreadable from the container’s point of view.

That’s why the recommended way to pull/push file in LXD is by using the lxc file pull and lxc file push commands which has LXD do any needed remapping of ownership information for you.