How to log all the processes running inside a Docker container?

docker, logging

Solution

It is possible to show all the processes running inside a container without login to terminal by using the following command. Of course, it is just like how one can see by using `ps -eaf`, so just add it to `docker exec`.

bash $ sudo docker exec -it test1 ps -eaf
PID   USER     TIME   COMMAND
    1 root       0:00 sh
    7 root       0:00 sh
   60 root       0:00 /bin/sh
   67 root       0:00 /bin/sh
   84 root       0:00 ps -eaf

Like it was mentioned, if you are already inside of a container, then just use `ps -eaf` command to see the running processes.

By the way, it is recommended to have one user application / process per container.

Problem

After having logged into the container using the command - ``` docker exec -it <container_name> ``` How do I check for all the processes running inside the container? Is "ps aux" the correct way to do it? Are there any better alternatives/approaches?

Original source