Search⌘ K

Container Processes

Explore how to inspect and manage processes running inside Docker containers. Understand the importance of the main process, learn to use commands like ps and docker exec, and analyze container details with docker inspect to effectively work with container lifecycles.

Inspecting container processes

Most containers only run a single process, which is the container’s main app process and always PID 1. Run a ps command to see the processes running in the container. For these commands to work, we’ll need to be connected to the session from the previous lesson.

$ docker exec -it webserver sh
/src # ps
PID USER TIME COMMAND
1 root 0:00 node ./app.js
13 root 0:00 sh
22 root 0:00 ps
Inspecting processes

The output shows three processes:

  • PID 1 is the main application process running the Node.js web app
  • PID 13 is the shell process our interactive session is connected to.
  • PID 22 is the ps command we just ran.
...