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

后端 未结 16 1391
情歌与酒
情歌与酒 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 18:55

    Maybe this do the trick:

    if [ -z $(docker ps -q) ]; then
        echo "There is not process currently running"
    else
        echo "There are processes running"
    fi
    

    Is that what you want? Hope it helps =)

提交回复
热议问题