0

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?

Andrew
  • 13
  • 4
  • Is this command just about running `ps` from inside a container? If there's application code involved, can you [edit] the question to include a [mcve], including how you're starting the container? A key goal of Docker is to isolate the container and host from each other, so a system-monitoring application is often better run outside a container so the isolation features don't cause problems. – David Maze Jul 02 '22 at 11:23

1 Answers1

0

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
anemyte
  • 17,618
  • 1
  • 24
  • 45