Debugging Containers
5 min read Quiz at the end
Debug crashed containers by overriding entrypoints, inspecting state, and using netshoot.
Debugging Containers
# Shell into running container
docker exec -it mycontainer sh
# Override entrypoint to debug failed build
docker run -it --entrypoint sh myapp:broken
# Check exit reason
docker inspect mycontainer | grep -A5 State
docker logs mycontainer 2>&1 | tail -50
# File diff since container started
docker diff mycontainer # A=added C=changed D=deleted
# Copy files out
docker cp mycontainer:/app/logs/error.log ./
# Network debugging
docker run --rm --network mynet nicolaka/netshoot
Topic Quiz · 2 questions
Test your understanding before moving on
1. Which command runs a shell in an already-running container?
💡 docker exec runs a new process inside an existing running container.
2. How do you override the ENTRYPOINT to debug a failing container?
💡 --entrypoint overrides the Dockerfile ENTRYPOINT so you can start a shell instead.