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

后端 未结 7 927
盖世英雄少女心
盖世英雄少女心 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:37

    You can use docker top command. This command lists all processes running within your container.

    For instance this command on a single process container on my box displays:

    UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
    root                14097               13930               0                   23:17               pts/6               00:00:00            /bin/bash
    

    All methods mentioned by others are also possible to use but this one should be easiest.

    Update:

    To simply get the main process id within the container use this command:

     docker inspect -f '{{.State.Pid}}' 
    

提交回复
热议问题