Finding Docker container processes? (from host point of view)

后端 未结 7 944
盖世英雄少女心
盖世英雄少女心 2020-12-07 12:17

I am doing some tests on docker and containers and I was wondering:

Is there a method I can use to find all process associated with a docker container by its name or

7条回答
  •  一个人的身影
    2020-12-07 12:55

    the process run in a docker container is a child of a process named containerd-shim (in Docker v18.09.4)

    • First figure out the process IDs of the containerd-shim processes.
    • For each of them, find their child process.

    pgrep containerd-shim
    
    7105
    7141
    7248
    

    To find the child process of parent process 7105:

    pgrep -P 7105
    

    7127


    In the end you could get the list with:

    for i in $(pgrep containerd-shim); do pgrep -P $i; done
    
    7127
    7166
    7275
    

提交回复
热议问题