Inspecting & Debugging Containers

Intermediate

Overview

When something misbehaves, docker logs shows a container's output; add -f to follow it live. docker exec lets you run a command (often a shell) inside a running container.

docker inspect dumps detailed JSON about a container or image — its mounts, networks, environment, and more. docker stats shows live CPU and memory usage.

These four commands cover the vast majority of day-to-day container troubleshooting.

Cheatsheet

docker logs -f <name>Follow a container's logs
docker exec -it <name> shOpen a shell inside it
docker inspect <name>Full JSON details
docker statsLive resource usage
docker top <name>Processes running inside

Try it

A safe, simulated terminal. Run the suggested commands to see typical output.

simulated terminal

Type a command and press Enter, or click a suggestion below to run it.

$

Quick quiz

1. Which command opens an interactive shell inside a running container?

2. What does adding -f to docker logs do?