Passing processes into Docker container

499 Views Asked by At

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?

1

There are 1 best solutions below

0
anemyte On BEST ANSWER

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