Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于remount_lxcfs的这个功能 #3

Open
markzhang0928 opened this issue Apr 11, 2018 · 12 comments
Open

关于remount_lxcfs的这个功能 #3

markzhang0928 opened this issue Apr 11, 2018 · 12 comments

Comments

@markzhang0928
Copy link

markzhang0928 commented Apr 11, 2018

最近的这个remount_lxcfs 是不是还没有实现哦,我看codecov上的代码还是空的。https://codecov.io/gh/alibaba/pouch/pull/885/diff?src=pr&el=tree#diff-Y2xpL21haW4uZ28=

@CodeJuan
Copy link

CodeJuan commented Apr 11, 2018

@markzhang0928 是的,这一块还没有实现。方法就是

  1. 将宿主机上lxcfs的上一层目录挂到容器里
-v /var/lib/lxc/:/var/lib/lxc/:shared  \
-v /var/lib/lxc/lxcfs/proc/uptime:/proc/uptime \
-v /var/lib/lxc/lxcfs/proc/swaps:/proc/swaps  \
-v /var/lib/lxc/lxcfs/proc/stat:/proc/stat  \
-v /var/lib/lxc/lxcfs/proc/diskstats:/proc/diskstats \
-v /var/lib/lxc/lxcfs/proc/meminfo:/proc/meminfo \
-v /var/lib/lxc/lxcfs/proc/cpuinfo:/proc/cpuinfo
  1. 在systemd的增加ExecStartPost=remount_lxcfs
  2. 在lxcfs进程重启之后,在容器里再mount一次mount -B "/var/lib/lxc/lxcfs/proc/$file" "/proc/$file"

@markzhang0928
Copy link
Author

markzhang0928 commented Apr 11, 2018

@CodeJuan thx~

但是我试过你在这里提到的方法,用nsenter 进行mount -B.
报错是:mount: mount point /proc/meminfo does not exist.

宿主上lxcfs进程重启后,容器中的/proc/$file文件会是这样

root@5d9039f89f8e:/# ls -la /proc/
ls: cannot access /proc/diskstats: Transport endpoint is not connected
ls: cannot access /proc/swaps: Transport endpoint is not connected
ls: cannot access /proc/uptime: Transport endpoint is not connected
ls: cannot access /proc/stat: Transport endpoint is not connected
ls: cannot access /proc/meminfo: Transport endpoint is not connected
ls: cannot access /proc/cpuinfo: Transport endpoint is not connected
...
-?????????   ? ?    ?       ?            ? cpuinfo
-?????????   ? ?    ?       ?            ? meminfo
-?????????   ? ?    ?       ?            ? stat
-?????????   ? ?    ?       ?            ? swaps
-?????????   ? ?    ?       ?            ? uptime

OS:

Distributor ID:	Debian
Description:	Debian GNU/Linux 8.6 (jessie)
Release:	8.6
Codename:	jessie

Kernel:

Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux

refs:
AliyunContainerService/pouch#140
lxc/lxcfs#193

@markzhang0928
Copy link
Author

markzhang0928 commented Aug 7, 2018

奥, 最近回顾了一下,找到原因了。 没有mount /var/lib/lxc 到容器的mount ns.

@JaeGerW2016
Copy link

lxcfs能不能以daemonset的形式在节点运行,ExecStartPost=remount_lxcfs用postStart的pod hook实现remount?

@markzhang0928
Copy link
Author

lxcfs能不能以daemonset的形式在节点运行,ExecStartPost=remount_lxcfs用postStart的pod hook实现remount?

remount 是可以,前提是容器里面有mount point.

@julyclyde
Copy link

求教,我用nsenter mount -B就可以成功;

docker exec进去mount -B就提示说
mount point is not a directory

这是为什么呢?

@ganker-z
Copy link

ganker-z commented Feb 8, 2021

奥, 最近回顾了一下,找到原因了。 没有mount /var/lib/lxc 到容器的mount ns.

请问下,怎么mount /var/lib/lxc 到容器的mount ns

@zxq1002
Copy link

zxq1002 commented Jun 25, 2021

奥, 最近回顾了一下,找到原因了。 没有mount /var/lib/lxc 到容器的mount ns.

请问下,怎么mount /var/lib/lxc 到容器的mount ns

同问,把宿主机的/var/lib/lxc mount到容器的/var/lib/lxc?

@JaeGerW2016
Copy link

JaeGerW2016 commented Jul 5, 2022 via email

@fjibj
Copy link

fjibj commented Jul 5, 2022

还是不行,请帮忙看看 @CodeJuan @markzhang0928 @JaeGerW2016

lxcfs是在宿主机上手工启停的
# /usr/bin/lxcfs -l /var/lib/lxc/lxcfs/

容器启动命令:
`docker run -dt -m 5g \

-v=/sys/fs/cgroup:/sys/fs/cgroup:ro \

-v=/var/lib/lxc/:/var/lib/lxc/:shared \

-v=/var/lib/lxc/lxcfs/proc/diskstats:/proc/diskstats:rw,rslave \

-v=/var/lib/lxc/lxcfs/proc/meminfo:/proc/meminfo:rw,rslave \

-v=/var/lib/lxc/lxcfs/proc/stat:/proc/stat:rw,rslave \

-v=/var/lib/lxc/lxcfs/proc/swaps:/proc/swaps:rw,rslave \

-v=/var/lib/lxc/lxcfs/proc/uptime:/proc/uptime:rw,rslave \

-v=/var/lib/lxc/lxcfs/proc/loadavg:/proc/loadavg:rw,rslave \

--name ddd \

XXXXX`

在宿主机上执行:
`# nsenter --target 14591 --mount -- mount -B /var/lib/lxcfs/proc/meminfo /proc/meminfo

mount: mount point /proc/meminfo does not exist`

在容器内执行:
`[root@master lxcfs]# mount -B "/var/lib/lxc/lxcfs/proc/cpuinfo" "/proc/cpuinfo"

mount: mount point /proc/cpuinfo is not a directory`

@JaeGerW2016
Copy link

前提是容器里面有mount point @fjibj

@fjibj
Copy link

fjibj commented Jul 5, 2022

怎么设置容器里面的mount point?

我在docker run时已经把/var/lib/lxc/挂进去了,
-v=/var/lib/lxc/:/var/lib/lxc/:shared \
还需要做其他设置吗?
@JaeGerW2016 @markzhang0928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants