Roadmap › Docker & Containers › Module: Production Practices
Lessons in this course (8)

7. Debugging containers

IntermediateMediumLesson 7 of 8
bash
docker logs --tail 100 api
docker inspect api                       # config, env, mounts, IP, health status
docker exec -it api sh                   # look around (not available in chiseled images)
docker stats                             # live CPU/memory
docker top api                           # processes
docker events                            # daemon events (OOM kills, restarts)
docker run --rm -it --entrypoint sh shop-api:1.0      # override entrypoint to inspect an image
docker cp api:/app/appsettings.json .                 # copy files out
docker history shop-api:1.0                           # layers and sizes

Common issues: app listening on localhost instead of 0.0.0.0 inside the container (ASP.NET Core images listen on all interfaces on 8080); wrong port mapping (80 vs 8080 after .NET 8); exit code 137 = killed (OOM or SIGKILL); 139 = segfault; container exits immediately because the main process ended; file permission errors when running as non-root; DNS between containers needs a user-defined network.