Docker inspect: read state and selected configuration
Ask Docker about a container
Inspect answers questions about the container object, such as its configured image and current state. Logs answer questions about what the application printed. Full inspection can contain extensive metadata, including environment values; select only fields relevant to your investigation.
Lab prerequisites
Use an approved disposable Linux-container lab only. Verify the active context (docker context show), CLI/daemon versions and that the instructor has reviewed and preloaded the BusyBox 1.37 fixture for the target platform; record its digest before use. The tag is inherited from earlier chapters, not a verified immutable identity. --pull=never avoids automatic downloads; --network none isolates normal network access for these local-only tasks. Verify each bm-v04 name is unused; if not, choose a fresh name consistently. Run host commands one at a time in Bash, stop on unexpected errors, and clean up only the container you created. If a fixture times out, inspect its state before retrying; remove only your stopped fixture. All snippets are static, not executed by ByteMind. Before any engine request, confirm the effective approved daemon endpoint, including DOCKER_HOST, DOCKER_CONTEXT and CLI overrides; do this privately in each terminal. Confirm the local tag still resolves to the approved image identity and platform. If any check fails, use the paper exercise instead. The network flag limits container networking, not the client-to-daemon connection. Use a lab with readable, local-only logging and an owner-set execution time limit; confirm your fixture identity before every cleanup.
Compare before and after start
Create a container without starting it. The first state should be created. Start it and check state and configured image: while the 300-second wait is active, expect running and busybox:1.37. After stopping, expect exited. The formatting expression is a Go template, not a shell variable. Single quotes keep it intact in a POSIX-style shell.
docker create --pull=never --network none --name bm-v04-inspect busybox:1.37 sleep 300docker container inspect --format '{{.State.Status}}' bm-v04-inspectdocker start bm-v04-inspectdocker container inspect --format '{{.State.Status}} {{.Config.Image}}' bm-v04-inspectdocker stop bm-v04-inspectdocker container inspect --format '{{.State.Status}}' bm-v04-inspectdocker rm bm-v04-inspectConfiguration is not proof of behavior
The configured image reference is useful for identifying intent, but it is not an immutable identity; image ID and repository digest are separate concepts covered in Chapter 3. running means the process is active, not that an HTTP service works. Inspect does not change a setting. Check actual application behavior separately when a lesson requires it. The container field .Image identifies the image ID associated with the container, while .Config.Image records its configured image reference. A tag can move later without changing the container’s original image.
Manual practice
Using the same sequence with a new fixture name, record only the three state labels. Explain why a full metadata dump is unnecessary and why the state check cannot establish application readiness.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Docker inspect: read state and selected configuration — Knowledge check
Apply the concepts from this lesson.
Which field in the example shows current state?
Does running prove that a web endpoint responds correctly?
Why prefer selected fields to sharing full inspection output?