I have the lxc, it has a running application. To edit the code of this application on own computer(Ubuntu 13.10), I want to mount a directory lxc. How can this be done?
for example
/var/lib/lxc/ubuntu_12_04/rootfs/home/
mounted in /mnt/lxc
I have the lxc, it has a running application. To edit the code of this application on own computer(Ubuntu 13.10), I want to mount a directory lxc. How can this be done?
for example
/var/lib/lxc/ubuntu_12_04/rootfs/home/
mounted in /mnt/lxc
Use "mount --bind"
man 8 mount
Example
Notes
Root has access to /var/lib/lxc/ubuntu_12_04/rootfs/home/ even without mounting.
The user id in the lxc instance should equal the user id in the host. Otherwise you may need to change users (
su someother_username
) or change file ownership (chown myuser: somefile.txt
.) Ubuntu starts at the same user id by default so if you're using the default user in both places, the user ids should equal.To check the user ids on files use
ls --numeric-uid-gid
orls -n
. Below you see a user id and group id of 1042.If you want to mount automatically a directory inside the lxc each time you start the lxc you can use the
lxc.mount.entry
directory inside/var/lib/lxc/ubuntu_12_04/config
file. With Something like:This will mount
/mnt/lxc
inside the lxc root filesystem aka rootfs athome/
directory.