0
0
Dockerdevops~10 mins

Listing containers (docker ps, docker ps -a) - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Listing containers (docker ps, docker ps -a)
Start
Run 'docker ps'
Show running containers
Run 'docker ps -a'
Show all containers (running + stopped)
End
The flow shows running 'docker ps' to list running containers, then 'docker ps -a' to list all containers including stopped ones.
Execution Sample
Docker
docker ps

docker ps -a
Lists running containers first, then lists all containers including stopped ones.
Process Table
StepCommandActionOutput ExampleNotes
1docker psList running containers onlyCONTAINER ID IMAGE STATUS NAMES abc123 nginx Up 2 hours webserverShows only containers currently running
2docker ps -aList all containers (running + stopped)CONTAINER ID IMAGE STATUS NAMES abc123 nginx Up 2 hours webserver def456 redis Exited (0) 3 hours redisdbShows all containers including stopped ones
💡 Commands complete after listing containers; no further action.
Status Tracker
VariableStartAfter 'docker ps'After 'docker ps -a'
Running Containers List[][{ID: 'abc123', Image: 'nginx', Status: 'Up 2 hours', Name: 'webserver'}][{ID: 'abc123', Image: 'nginx', Status: 'Up 2 hours', Name: 'webserver'}]
All Containers List[][][{ID: 'abc123', Image: 'nginx', Status: 'Up 2 hours', Name: 'webserver'}, {ID: 'def456', Image: 'redis', Status: 'Exited (0) 3 hours', Name: 'redisdb'}]
Key Moments - 2 Insights
Why does 'docker ps' show fewer containers than 'docker ps -a'?
'docker ps' shows only running containers (see execution_table step 1), while 'docker ps -a' shows all containers including stopped ones (step 2).
What does the 'Exited' status mean in 'docker ps -a' output?
'Exited' means the container has stopped running but still exists on the system, visible only with 'docker ps -a' (execution_table step 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what does 'docker ps' list at step 1?
AOnly running containers
BOnly stopped containers
CAll containers including stopped ones
DNo containers at all
💡 Hint
Check the 'Output Example' column in execution_table row for step 1.
At which step does the command show containers with status 'Exited'?
AStep 1
BBoth steps
CStep 2
DNeither step
💡 Hint
Look at the 'Output Example' column for 'Exited' status in execution_table.
If a container is stopped, which command will show it?
Adocker ps
Bdocker ps -a
Cdocker start
Ddocker run
💡 Hint
Refer to variable_tracker showing 'All Containers List' after 'docker ps -a'.
Concept Snapshot
docker ps: Lists only running containers.
docker ps -a: Lists all containers including stopped ones.
Use 'docker ps' to see active containers.
Use 'docker ps -a' to see full container history.
'Exited' status means container is stopped but exists.
These commands help manage container states quickly.
Full Transcript
This visual execution shows how 'docker ps' lists only running containers, while 'docker ps -a' lists all containers including stopped ones. Step 1 runs 'docker ps' and outputs running containers. Step 2 runs 'docker ps -a' and outputs all containers with their statuses. Variables track container lists after each command. Key moments clarify why outputs differ and what 'Exited' means. The quiz tests understanding of these differences and command outputs.