mit einem Klick
container-debugging
Debug running containers with log analysis, shell access, state inspection, and network diagnostics.
Menü
Debug running containers with log analysis, shell access, state inspection, and network diagnostics.
| name | container-debugging |
| description | Debug running containers with log analysis, shell access, state inspection, and network diagnostics. |
| standards-version | 1.10.0 |
Use this skill when:
docker_listContainers to find it)docker_listContainers to find the target and its current state.docker_containerLogs to get recent output. Look for stack traces, connection errors, or permission denied messages.docker_inspectContainer to check environment variables, mounts, network settings, restart count, and exit code.State.OOMKilled. If true, the container ran out of memory.docker exec -it <container> sh (or bash if available) to investigate interactively.ping, curl, wget, or nslookup to verify DNS and connectivity.docker cp to pull log files, configs, or core dumps out of the container.docker stats or docker_diskUsage to identify resource pressure.User: My API container keeps restarting. How do I figure out why?
Agent: Let me check the container state and logs.
First, I'll call docker_listContainers to find the container. Then:
# Check the last 100 lines of logs
docker logs --tail 100 my-api
# Look at the container's exit code and restart count
docker inspect my-api --format '{{.RestartCount}} restarts, exit code {{.State.ExitCode}}, OOMKilled={{.State.OOMKilled}}'
Common causes by exit code:
docker killUser: It's exit code 137 and OOMKilled is true.
Agent: The container is running out of memory. Options:
# Check current memory usage across all containers
docker stats --no-stream
# Increase the memory limit in compose
services:
api:
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
Or investigate the memory leak by shelling in:
docker exec -it my-api sh
# Inside the container:
cat /proc/meminfo
top -o %MEM
User: How do I debug network issues between containers?
Agent:
# Shell into the source container
docker exec -it my-api sh
# Test DNS resolution
nslookup db
# Expected: resolves to the db container's IP on the shared network
# Test TCP connectivity
wget -qO- http://db:5432 || echo "connection refused or timeout"
# If ping is available
ping -c 3 db
# Check what networks the container is on
docker inspect my-api --format '{{json .NetworkSettings.Networks}}' | python3 -m json.tool
If DNS fails, verify both containers are on the same Docker network. If you're using compose, they share a default network. If using standalone containers, connect them:
docker network connect my-network my-api
| Tool | Purpose |
|---|---|
docker_listContainers | Find the target container and check its status (running, exited, restarting) |
docker_containerLogs | Pull recent logs to find error messages and stack traces |
docker_inspectContainer | Check exit code, OOMKilled flag, env vars, mounts, network config, restart count |
docker_listNetworks | List Docker networks to verify containers share a network |
docker_listVolumes | Verify volume mounts are present and pointing to the right paths |
docker_diskUsage | Check if disk pressure is causing failures |
docker_systemInfo | Check Docker engine version, total memory, and runtime configuration |
Typical debugging flow with MCP:
1. docker_listContainers - find the container, note its state
2. docker_containerLogs with containerId - read the error output
3. docker_inspectContainer with containerId - check:
- State.ExitCode (why it stopped)
- State.OOMKilled (memory issue)
- State.RestartCount (how many times it restarted)
- Mounts (are volumes attached correctly)
- NetworkSettings.Networks (is it on the right network)
4. docker_listNetworks - verify network topology
Copying files out for analysis:
# Pull a log file from a stopped container
docker cp my-api:/app/logs/error.log ./error.log
# Pull the entire config directory
docker cp my-api:/app/config ./container-config/
docker cp to extract files, or add a debug sidecar container that shares the same network/volumes.--rm containers they vanish. Use docker_containerLogs before the container is removed, or configure a logging driver that persists.docker_listNetworks and docker_inspectContainer to verify.State.OOMKilled: true confirms it. Always check the inspect output, not just the exit code.curl, wget, or nc to test the actual port.RestartCount: 50 is stuck in a crash loop. The logs from the most recent attempt may not show the root cause if earlier failures differ.docker cp to extract what you need.--tail on logs - docker logs without --tail dumps the entire log history. For long-running containers this can be gigabytes. Always use --tail 100 or --since 5m.Multi-stage pipelines, sidecar patterns, healthchecks, init containers, signal handling, and graceful shutdown.
Use Docker in CI/CD pipelines with GitHub Actions, multi-platform builds, registry push, and layer caching strategies.
Write, debug, and optimize docker-compose.yml files with service definitions, networking, volumes, and healthchecks.
Manage Docker contexts for multi-host and remote Docker engine workflows
Set up development environments with Docker including hot reload, dev containers, bind mounts, and database containers.
Docker Content Trust - image signing, verification, key management, and CI/CD signing pipelines