Inspecting Details
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 18 of 40.
Docker stores a lot of detail about every container: its status, the image it came from, its network settings, and more. The docker inspect command shows all of it as JSON.
That is usually more than you want. The --format flag lets you pull out just one field using a Go-template placeholder:
docker inspect --format "{{.State.Status}}" webThis prints just the container's status, for example running. Other handy placeholders include {{.Config.Image}} for the image name. The format string turns a wall of JSON into the single value you actually need.
Challenge
EasyStart a detached nginx container named app, then use docker inspect with --format "{{.State.Status}}" to print just its status.
Cheat sheet
Use docker inspect to view container details as JSON. The --format flag with a Go-template extracts a specific field:
docker inspect --format "{{.State.Status}}" webUseful placeholders:
{{.State.Status}}— container status (e.g.running){{.Config.Image}}— image name
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.