【发布时间】:2019-03-23 20:06:11
【问题描述】:
我有一个lxd 容器,名为master。我发现它的根目录可以在:
/var/lib/lxd/containers/master/rootfs/home/ubuntu/
所以,我将我的文件夹 tars 转移到了这个地址。请注意,tars 有两个文件。
现在,我知道tars 的用户ID 和组ID 是root。另一方面,容器中所有其他文件的用户 ID 和组 ID 为 166536。
因此,对于文件夹和文件,我使用sudo chown 166536 <file/folder name> 更改用户 ID,并使用sudo chown :166536 <file/folder name> 更改组 ID。
有一次,我这样做了,我希望 tars 可以从容器 master 访问,但这并没有发生。谁能告诉我我错过了什么?
这是一个方法,我在reddit上找到的:
是的,这就是答案,使用非特权容器运行你 无法查看 LXD 主机上的权限,因此显示为 无人:无人。在某种程度上很愚蠢,因为您可以将文件夹安装到 容器并查看其上的文件..
为了将来参考,对于遇到此问题的任何人,这是步骤 我做了(它可能不是正确的,但它有效)
sudo mkdir /tmp/share adduser subsonic --shell=/bin/false --no-create-home --system --group --uid 6000 (this is a "service account") sudo chown -R subsonic: /tmp/share lxc exec Test -- /bin/bash mkdir /mnt/share adduser subsonic --shell=/bin/false --no-create-home --system --group --uid 6000 (important that the uid is the same) exit lxc stop Test lxc config edit Test (add the line security.privileged: "true" right bellow config: save and exit) lxc start Test lxc config device add MyMusic MyLibrary disk source=/tmp/share path=/mnt/share lxc exec Test -- /bin/bash ls /mnt/share/ (note that the subsonic user is there) exit很遗憾,我找不到将用户映射到 非特权容器。如果有人知道,请告诉我。
基本上,为主机和容器创建一个普通用户。有没有比这种方法更好的方法?
【问题讨论】: