Interview Q&A / Docker & Kubernetes

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How do you check a container's IP address, environment variables and resource usage?

SHORT ANSWER

docker inspect shows full JSON details such as IP, env vars, mounts and state, and -f with a Go template pulls out one field. docker stats shows live CPU, memory and network usage.

Explain it simply

docker inspect is the Aadhaar record of a container: every detail registered about it. docker stats is the live heart-rate monitor.

Inspect prints a large JSON document: network settings and IP, environment variables, mounts, restart policy, exit code and more. Reading it all is slow, so pass -f with a Go template to pick one field. docker stats streams CPU percent, memory used against the limit, network I/O and process count for running containers, refreshing every second. --no-stream prints one snapshot. docker top web lists the processes inside, and docker port web shows published ports.

These are the first tools to reach for when a container is slow, memory-hungry or unreachable.

Example

bash
docker inspect web | less
docker inspect -f '{{.NetworkSettings.IPAddress}}' web
docker inspect -f '{{json .Config.Env}}' web
docker stats --no-stream
docker top web

What to say in the interview

"docker inspect gives the full JSON for a container and I use -f with a template to extract a field like the IP or env vars. docker stats gives live CPU and memory use, and docker top lists its processes."

Common mistakes

  • Reading the IP of the default bridge and hard-coding it; it changes on restart, use names on a user-defined network.

#docker#commands#debugging

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.