Production Docker · 8 min read · Intermediate
Debugging Containers: logs, exec & inspect
Diagnose failing containers in seconds using docker logs, docker exec -it, docker inspect, and docker stats.
What you'll learn
- Tail recent container logs with docker logs --tail 100 -f
- Open an interactive shell inside a running container with docker exec -it
- Inspect live CPU and RAM usage per container using docker stats
When a container exits immediately or misbehaves, follow this 3-step triage checklist:
docker ps -a-> Check exit code (Exit 137= OOM killed;Exit 1= app crash).docker logs --tail 100 <name>-> Read the exact crash stack trace.docker exec -it <name> sh-> Step inside a running container to test env vars, DNS, or files.
Fill-in-the-Blank Exercise
Open Shell Inside Running Container
Launch an interactive sh shell inside the running container named api.
docker - api shLive Triage Command Lab
Bashdebug_docker.sh
Expected OutputClick “Run Live” to compile with GNU Bash
# 1. See exited containers and exit codes docker ps -a # 2. Stream last 50 log lines docker logs --tail 50 -f api # 3. Live CPU/RAM monitor docker stats --no-stream
Check Your Understanding
Score: 0 / 1
1. What does Exited (137) on a Docker container usually indicate?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.