Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu 如何从lxc装入文件夹_Ubuntu_Mount_Lxc - Fatal编程技术网

Ubuntu 如何从lxc装入文件夹

Ubuntu 如何从lxc装入文件夹,ubuntu,mount,lxc,Ubuntu,Mount,Lxc,我有lxc,它有一个正在运行的应用程序。 要在自己的计算机(Ubuntu13.10)上编辑这个应用程序的代码,我想挂载一个目录lxc。如何做到这一点 比如说 /var/lib/lxc/ubuntu\u 12\u 04/rootfs/home/ 安装在/mnt/lxc中使用“安装-绑定” -B、 --绑定 例子 #做一个挂载点 sudo mkdir/mnt/lxc #在装载点上装载现有目录 mount--bind/var/lib/lxc/ubuntu_12_04/rootfs/home//mnt/

我有lxc,它有一个正在运行的应用程序。 要在自己的计算机(Ubuntu13.10)上编辑这个应用程序的代码,我想挂载一个目录lxc。如何做到这一点

比如说

/var/lib/lxc/ubuntu\u 12\u 04/rootfs/home/

安装在/mnt/lxc中

使用“安装-绑定” -B、 --绑定

例子
#做一个挂载点
sudo mkdir/mnt/lxc
#在装载点上装载现有目录
mount--bind/var/lib/lxc/ubuntu_12_04/rootfs/home//mnt/lxc
笔记
  • Root用户可以访问/var/lib/lxc/ubuntu\u 12\u 04/rootfs/home/即使没有挂载

  • lxc实例中的用户id应等于主机中的用户id。否则,您可能需要更改用户(
    su someother_username
    )或更改文件所有权(
    chown myuser:somefile.txt
    )Ubuntu默认以相同的用户id启动,因此如果您在两个位置都使用默认用户,则用户id应该相等

  • 要检查文件上的用户ID,请使用
    ls--numeric uid gid
    ls-n
    。下面是用户id和组id 1042

    #显示用户和组ID
    ls-n
    -rw-r--r--1 1042 1042 0 May 15 15:31 example.txt
    

  • 如果您想在每次启动lxc时自动挂载lxc中的目录,您可以使用
    lxc.mount.entry
    中的
    /var/lib/lxc/ubuntu\u 12\u 04/config
    文件中的目录。比如:

    lxc.mount.entry = /mnt/lxc home/ none bind 0 0
    

    这将装载
    /mnt/lxc
    home/
    目录下的lxc根文件系统aka rootfs中。

    这与
    lxc
    没有多大关系。主机操作系统上的
    rootfs
    目录只是一个常规目录,您可以从容器外部安全地写入它,您可以根据需要导出它(Samba、NFS等)
    lxc.mount.entry = /mnt/lxc home/ none bind 0 0