How to determine if a process runs inside lxc/Docker?

后端 未结 16 1358
情歌与酒
情歌与酒 2020-11-28 18:15

Is there any way to determine if a process (script) runs inside an lxc container (~ Docker runtime)? I know that some programs are able to detect whether they run inside a v

16条回答
  •  时光取名叫无心
    2020-11-28 19:05

    This SO Q&A: "Find out if the OS is running in a virtual environment"; though not the same as the OP's question, it does indeed answer common cases of finding which container you're in (if at all).

    In particular, install and read the code of this bash script which seems to work pretty well:

    virt-what :

    sudo apt install virt-what
    

提交回复
热议问题