Reputation: 2886
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?
Upvotes: 37
Views: 77896
Reputation: 21359
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 $ 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.
Upvotes: 25
Reputation: 843
Extending from the answer of @Slawomir
And With ps option, docker top [--help] CONTAINER [ps OPTIONS]
docker top <container_id> -eo pid,cmd
Upvotes: 17
Reputation: 8497
You can use dedicated command top to list process in docker container, regardless of the operating system in container.
docker top <container>
Upvotes: 64