docker-internals
Use when the user asks how containers work, Linux namespaces and cgroups v2, OverlayFS layers and copy-on-write, containerd and runc, the OCI runtime spec…
от j4flmao★ 47 звёзд на GitHub
Установить docker-internals в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Docker and Container Internals
Purpose
A container is an ordinary Linux process tree started with isolated namespaces, constrained by cgroups, with reduced privileges, and a root filesystem assembled from image layers. Knowing this explains OOM kills, PID 1 signal problems, file-change behaviour, and what "privileged" really grants.
Agent Protocol
Trigger
"how do containers work", "docker internals", "namespaces", "cgroups", "overlayfs", "copy on write", "containerd", "runc", "OCI runtime", "PID 1", "OOM killed".
Input Context
- Host OS/kernel, cgroup version (
stat -fc %T /sys/fs/cgroup→cgroup2fsmeans v2). - Runtime (Docker Engine, containerd via Kubernetes, Podman).
- Symptom being debugged.
Output Artifact
Explanation + inspection commands + fix. No file unless requested.
Response Format
Mechanism: {namespace|cgroup|capability|seccomp|overlayfs|runtime}
Evidence: {commands and expected output}
Explanation: {...}
Fix: {run flags / Dockerfile / K8s field}
Completion Criteria
- Symptom mapped to a specific kernel mechanism.
- Inspection commands given to confirm.
Runtime Stack
flowchart LR
CLI[docker CLI] --> D[dockerd]
D --> C[containerd]
C --> S[containerd-shim-runc-v2]
S --> R[runc: creates namespaces/cgroups, execs process]
K[kubelet] -->|CRI gRPC| C
- Images and runtimes follow the OCI Image and Runtime specs; any OCI image runs on containerd/CRI-O/Podman.
- Kubernetes removed dockershim in 1.24; kubelet talks CRI to containerd or CRI-O directly. Images built with Docker still work.
- The shim keeps containers running when containerd/dockerd restart.
Namespaces (isolation of what a process can see)
| Namespace | Isolates |
|---|---|
| PID | Process IDs (container's first process is PID 1) |
| NET | Interfaces, routes, iptables, ports |
| MNT | Mount table / root filesystem |
| UTS | Hostname, domain name |
| IPC | SysV IPC, POSIX message queues |
| USER | UID/GID mapping (root in container → unprivileged on host when used) |
| CGROUP | View of the cgroup hierarchy |
| TIME | CLOCK_MONOTONIC/BOOTTIME offsets (kernel ≥ 5.6) |
Inspect: lsns, ls -l /proc/<pid>/ns, enter with nsenter -t <pid> -n -m .... |
cgroups v2 (limits on what a process can use)
- Memory:
memory.max(hard limit → OOM kill of a process in the cgroup),memory.high(throttling/reclaim). Docker--memorysetsmemory.max. Checkmemory.eventsforoom_killcounts. - CPU:
cpu.max= quota/period (Docker--cpus=1.5→150000 100000); exceeding quota causes throttling (cpu.stat→nr_throttled).cpu.weightsets relative share under contention. - PIDs:
pids.maxstops fork bombs (--pids-limit). - I/O:
io.maxfor bandwidth/IOPS limits. Most current distributions default to cgroup v2; runtimes need the systemd cgroup driver configured consistently with the kubelet.
Privileges
- Capabilities: Docker drops most capabilities by default;
--cap-drop=ALL --cap-add=NET_BIND_SERVICEfor minimal sets. - seccomp: default profile blocks dangerous syscalls (e.g.
kexec_load,mountin most cases). --privileged: all capabilities, all devices, no seccomp/AppArmor confinement — effectively root on the host. Avoid.- Rootless / user namespaces: Docker rootless mode, Podman rootless, Kubernetes
hostUsers: false.
Image Layers and OverlayFS
- Each Dockerfile instruction that changes the filesystem creates a layer (a tar diff), content-addressed by digest.
- At runtime,
overlay2stacks read-only lower layers + one writable upper layer; reads fall through to the topmost layer containing the file. - Modifying a lower-layer file triggers copy-up of the whole file to the upper layer (expensive for big files); deleting creates a whiteout file.
- Deleting a file in a later layer does not shrink the image — the earlier layer still contains it. Clean up in the same
RUNor use multi-stage builds. - Write-heavy data (databases, logs) belongs in volumes, which bypass OverlayFS.
PID 1 Behaviour
- The kernel doesn't apply default signal handlers to PID 1 in a namespace: if the app doesn't handle SIGTERM,
docker stopwaits for the timeout then SIGKILLs. - PID 1 must reap zombie children. Use
docker run --init(tini) ortini/dumb-initas entrypoint for apps that spawn children. - Use exec-form
ENTRYPOINT ["app"]; shell form runs/bin/sh -cas PID 1, which doesn't forward signals.
Debugging Recipes
docker inspect --format '{{.State.Pid}} {{.State.OOMKilled}}' <ctr>
cat /sys/fs/cgroup/system.slice/docker-<id>.scope/memory.events # path varies by driver
docker stats --no-stream
nsenter -t "$(docker inspect -f '{{.State.Pid}}' <ctr>)" -n ss -tlnp # sockets inside netns
docker run --rm -it --pid=container:<ctr> --net=container:<ctr> nicolaka/netshoot # debug sidecar
Anti-Patterns
--privilegedor mounting/var/run/docker.sockinto app containers (host root).- Memory limit with
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл docker-internals?
Use when the user asks how containers work, Linux namespaces and cgroups v2, OverlayFS layers and copy-on-write, containerd and runc, the OCI runtime spec, container PID 1 and signals, or why a container is OOM killed. Explains container primitives for debugging and hardening. Not for Dockerfile authoring (use docker-patterns) or image scanning (use security-container-security).
Как установить скилл docker-internals?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл docker-internals запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…