Accessing LXC container's filesystem from host
I use the following method for backup using rsync
:
Using the pid of the container's init process, you can get it using
# list all hosts:
lxc-ls -f -Fname,pid
# or get pid of one host:
lxc-ls -f -Fpid mycontainer
PID
-----
13323
Using this information, you can access the host's rootfs using the /proc filesystem.
cat /proc/13323/root/etc/hostname
# returns: "mycontainer"