Search code examples
dockerhtop

Passing processes into Docker container


let's say, I'm trying to get 'visible' all processes on docker host inside my container. Is it possible to pass they in, so ps or htop could make them printed?


Solution

  • There is the --pid flag and with --pid=host you can start container in host's pid namespace:

    ❯ docker run --rm --pid=host debian:buster bash -c 'ls /proc -1 | wc -l'
    489
    

    Same goes for docker-compose:

    version: "3"
    services:
      test:
        pid: host