list process inside docker container [closed]

I have docker image starting from python:3.10-slim.
As the container running (name container_a), I would like to check the process running inside the container.

  1. docker top container_a: I am able to see three threads.
  2. docker exec container_a ps: executable not found in $PATH
  3. docker exec -it container_a sh: I am able to enter inside the container, and again I could not find ps or top under /bin

Anyone knows other command to list the process?

Thank you very much!

I have tried search command to list processes in Linux. It seems that both ps and top are common ones but neither works in the Slim linux.

  • Does this answer your question? ps command doesn’t work in docker container

    – 

  • 1

    The point of slim is that it only includes a very “slim” set of utilities, and apparently that does not include ps. You’ll have to install it like in the linked duplicate, or use docker top.

    – 

  • 1

    There’s probably only one process, whatever your Dockerfile specified as its CMD. What is your goal with this?

    – 

As highlighted by other comments, -slim tags are meant to, well, be slim. That images contain just what the main application needs to work, not what you need for interactive use. If you really want to, try:

docker run -it python:3.10-slim sh     
apt update && apt install procps
ps

This adds a few megabytes to the original image. To retain changes, use docker tag or docker commit, or a custom Dockerfile that RUNs previous apt commands

Leave a Comment