【发布时间】:2014-06-24 03:35:37
【问题描述】:
[Updated1] 我有一个shell,它会在一些函数中改变TCP内核参数,但是现在我需要让这个shell在Docker容器中运行,也就是说,shell需要知道它在一个容器中运行并停止配置内核。
现在我不知道如何实现,这里是容器内/proc/self/cgroup 的内容:
9:hugetlb:/
8:perf_event:/
7:blkio:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct:/
2:cpu:/docker/25ef774c390558ad8c4e9a8590b6a1956231aae404d6a7aba4dde320ff569b8b
1:cpuset:/
我可以使用上面的任何标志来确定此进程是否在容器内运行?
[Updated2]:我也注意到Determining if a process runs inside lxc/Docker,但在这种情况下似乎不起作用,我的容器/proc/1/cgroup中的内容是:
8:perf_event:/
7:blkio:/
6:freezer:/
5:devices:/
4:memory:/
3:cpuacct:/
2:cpu:/docker/25ef774c390558ad8c4e9a8590b6a1956231aae404d6a7aba4dde320ff569b8b
1:cpuset:/
没有 /lxc/containerid
【问题讨论】:
-
不是一个很清楚的问题。为什么需要这个?
-
@fish no /lxc/
在我的情况下,请参阅更新 -
@HenkLangeveld 内核参数在 Docker 容器中是只读的,所以我需要知道我的 shell 是否在容器中运行并在我的 shell 中禁用内核功能。查看更新。
-
脚本中的一些步骤尝试修改内核参数,在Docker中运行时需要跳过。清除。
标签: shell docker containers