2017年5月18日 星期四

[ 常見問題 ] How to check if a process is running inside docker container

Source From Here
Question
As title. How do I know whether I am inside a Container or not?

How-To
To check inside a Docker container if you are inside a Docker container or not can be done via /proc/1/cgroup. As this post suggests you can to the following:
# cat /proc/1/cgroup | grep memory // Now we are at host
8:memory:/

# d run -it fe5fb5242816 bash // Launch a Container
[root@3c6d29cf7fd8 /]# cat /proc/1/cgroup | grep memory // Now we are in a Container
8:memory:/docker/3c6d29cf7fd8763dd57abd815244190a5a267098235a1f69bd341b9fc2c83e35


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...