-
Notifications
You must be signed in to change notification settings - Fork 563
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
运行之后关闭之后,ubuntu的/proc就没有了 #41
Comments
http://old-releases.ubuntu.com/releases/14.04.0/ubuntu-14.04-desktop-amd64.iso |
请问这个问题怎么解决的呢 |
发现是systemd的锅... |
kernel: 5.0.4 |
|
@readlnh 赞,方便的话可以把适配代码提交PR到项目中,感谢! |
我可以尝试下,不过不知道应该提交到哪个分支 |
@readlnh master branch |
xianlubird/mydocker#41 (comment) ``` // systemd 加入linux之后, mount namespace 就变成 shared by default, 所以你必须显示 //声明你要这个新的mount namespace独立。 syscall.Mount("", "/", "", syscall.MS_PRIVATE | syscall.MS_REC, "") defualtMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV syscall.Mount("proc", "/proc", "proc", uintptr(defualtMountFlags), "") ``` 开个分支测试,如果失败,那么虚拟机回滚
* 来自 xianlubird/mydocker#41 (comment) ``` // systemd 加入linux之后, mount namespace 就变成 shared by default, 所以你必须显示 //声明你要这个新的mount namespace独立。 syscall.Mount("", "/", "", syscall.MS_PRIVATE | syscall.MS_REC, "") defualtMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV syscall.Mount("proc", "/proc", "proc", uintptr(defualtMountFlags), "") ``` 开个分支测试,如果失败,那么虚拟机回滚 这是一个Rebase合并 全部的合并分别进行了测试,最后修复了 #3 但 wwcdocker run -ti busybox sh 运行之后并不会获得 sh 进程直接会结束,需要在后续的commit中修复
* 来自 `https://github.com/xianlubird/mydocker/issues/41#issuecomment-478799767` ``` // systemd 加入linux之后, mount namespace 就变成 shared by default, 所以你必须显示 //声明你要这个新的mount namespace独立。 syscall.Mount("", "/", "", syscall.MS_PRIVATE | syscall.MS_REC, "") defualtMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV syscall.Mount("proc", "/proc", "proc", uintptr(defualtMountFlags), "") ``` 开个分支测试,如果失败,那么虚拟机回滚 这是一个Rebase合并 全部的合并分别进行了测试,最后修复了 #3 但 wwcdocker run -ti busybox sh 运行之后并不会获得 sh 进程直接会结束,需要在后续的commit中修复
请问:syscall.Mount("", "/", "", syscall.MS_PRIVATE | syscall.MS_REC, "")和在命令行输入unshare -m的效果一样吗? |
共享子树感觉理解不到,谁有好的资料可以分享下吗? |
厉害了,发现的步骤是怎样的呢? 的确解决了我的问题。 我用腾讯云centos开发, 每次运行后。 不仅需要重新 mount。 而且再用ssh连机器 都连不上~~~ 加上 syscall.Mount("", "/", "", syscall.MS_PRIVATE | syscall.MS_REC, "") 后就好了 |
感谢 @readlnh 的解答! 这里补充一下 mount 官方文档的完整解释: https://man7.org/linux/man-pages/man7/mount_namespaces.7.html#NOTES The propagation type assigned to a new mount depends on the Notwithstanding the fact that the default propagation type for Since, when one uses unshare(1) to create a mount namespace, the
To prevent this, one can use the --propagation unchanged option An application that creates a new mount namespace directly using
For a discussion of propagation types when moving mounts |
No description provided.
The text was updated successfully, but these errors were encountered: