Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
debugging Docker Docker & Containers: From Zero to Production Docker Containers Module 3 — Working with Containers

Container Logging and Inspection — docker logs and docker inspect

Reviewed & accurate
AI Summary

What You'll Learn

Beginner

  • How to view and follow container logs
  • How to inspect container details
  • How to use logs and inspect for debugging
Terminalbash
# Follow logs
docker logs -f web

# Last 50 lines
docker logs --tail 50 web

# Inspect container
docker inspect web

# Get just the IP
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web
Terminalbash
# Live resource usage
docker stats

# Processes inside container
docker top web

Practical Exercise

Run docker logs -f <name>
Run docker inspect <name>
Run docker stats

Key Takeaways

  • docker logs -f follows logs in real time.
  • docker inspect shows detailed JSON.
  • docker stats shows live CPU/memory.
  • Debug: docker ps → docker logs → docker inspect → docker exec.
Previously: Lesson 17 covered detached mode.
Today: You learned: View logs, inspect container details, and debug issues.
Next: Lesson 19 covers docker exec.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments