Docker 101 : Sharing the PID namespace with the host machine

For administrative reasons a container might need to have access to the processes running on the host machine or on another container on the same host.

In docker, we could achieve that using the "--pid=host" parameter on the command line, when creating our container.

We create a container using the below command. 
For our example, we will use "Alpine", which is a very small distribution of Linux.

After downloading the image of "Alpine", because it was not available locally, we get a command prompt.

At the command prompt, we type the command "ps" to see the processes running in the PID namespace of our "Alpine" container:

We can see that we also have access to the processes running on the host machine.


We can even have access from our "Alpine" container to processes from other containers that are running on the same host.


Leave as a comment: