[lxc-users] lxd access from host to container rootfs

Serge E. Hallyn serge at hallyn.com
Sat Dec 8 04:25:10 UTC 2018


On Wed, Dec 05, 2018 at 02:55:33PM +0100, Ingo Baab wrote:
> Hello All,
> how can I access the LXD/LXC containers rootfs from the host system?
> (if I am using ubuntu18.04 with snap lxc --version 3.7 on loopback-ZFS)
> 
> On other (real ZFS-based and U16.04) server I can access:
> 
>     "/var/lib/lxd/containers/{$containername}/rootfs/"
> 
> Any hints?
> Ingo

Well, I'm sure there is a better answer, but as I don't run the
snap version of lxd, i'm not sure of "the right" way, so...

the first thing you can do, if the container is running, is 

pid=$(lxc info $containername | awk '/Pid/ { print $2 }')
ls /proc/$pid/root

You also should be able to look at the open fds in the running
lxd for a hint as to where the info is being kept,

pid=$(pidof lxd | awk '{ print $1 }')
ls -l /proc/$pid/fd | grep $containername
or
ls -l /proc/$pid/fd | grep database


More information about the lxc-users mailing list