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.
We'll cover the following...
We'll cover the following...
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 # psPID USER TIME COMMAND1 root 0:00 node ./app.js13 root 0:00 sh22 root 0:00 ps
Inspecting processes
The output shows three processes:
PID 1is the main application process running the Node.js web appPID 13is the shell process our interactive session is connected to.PID 22is thepscommand we just ran.