0
0
Dockerdevops~10 mins

Inspecting container details in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Inspecting container details
Start: Have running container
Run 'docker ps' to list containers
Choose container ID or name
Run 'docker inspect <container>'
View detailed JSON info about container
Use info for debugging or monitoring
This flow shows how to list running containers, pick one, and inspect its detailed information using Docker commands.
Execution Sample
Docker
docker ps
# Lists running containers

docker inspect my_container
# Shows detailed info about 'my_container'
Lists running containers and then inspects details of a chosen container.
Process Table
StepCommand RunActionOutput Summary
1docker psList running containersShows container IDs, names, status, ports
2docker inspect my_containerGet detailed infoOutputs JSON with config, state, network, mounts
3Parse JSON outputRead container detailsSee IP address, volumes, environment variables
4Use info for troubleshootingApply knowledgeFix issues or monitor container health
5EndNo further commandsInspection complete
💡 Inspection ends after detailed container info is retrieved and reviewed
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
container_listemptylist of running containersunchangedunchangedunchanged
selected_containernonenonemy_containermy_containermy_container
container_detailsnonenoneraw JSON dataparsed JSON dataparsed JSON data
Key Moments - 3 Insights
Why do we run 'docker ps' before 'docker inspect'?
Because 'docker ps' shows which containers are running and their IDs or names, so you know what to inspect. See execution_table step 1 and 2.
What kind of information does 'docker inspect' provide?
'docker inspect' outputs detailed JSON including container config, network settings, and state. This is shown in execution_table step 2 and 3.
Can you inspect a container that is not running?
Yes, 'docker inspect' works on any container by ID or name, running or stopped. But 'docker ps' only lists running containers, so you might need 'docker ps -a' to see all.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what command lists running containers?
Adocker inspect my_container
Bdocker run
Cdocker ps
Ddocker stop
💡 Hint
Check execution_table row 1 under 'Command Run'
At which step do we get the detailed JSON info about the container?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Look at execution_table row 2 'Action' and 'Output Summary'
If you want to inspect a stopped container, what should you do differently?
AUse 'docker ps' as usual
BUse 'docker ps -a' to list all containers
CRestart the container first
DYou cannot inspect stopped containers
💡 Hint
Refer to key_moments about inspecting stopped containers
Concept Snapshot
docker ps
# Lists running containers

docker inspect <container>
# Shows detailed JSON info about the container

Use 'docker ps -a' to see all containers including stopped ones

Inspect output helps debug and monitor container state
Full Transcript
To inspect container details, first list running containers with 'docker ps'. This shows container IDs and names. Then choose a container and run 'docker inspect <container>' to get detailed JSON info about its configuration, state, network, and mounts. This info helps you understand the container's environment and troubleshoot issues. You can inspect stopped containers by listing all containers with 'docker ps -a'.