history
- Docker created containerd originally as a component of its own engine to separate “high-level” management from “low-level” execution.
- Later, Docker donated containerd to the CNCF (Cloud Native Computing Foundation).
- Kubernetes then adopted containerd as its runtime to remove its dependency on the full Docker daemon (the “Docker Shim” removal), because Kubernetes only needed the “running containers” part, not the full Docker UI/Network/Build stack.
So today:
- Docker USES containerd (as its internal engine).
- Kubernetes USES containerd (directly, skipping Docker).
Both tools rely on the same underlying containerd daemon to actually manage processes and images on Linux. If you kill containerd , you break both Docker and Kubernetes on that node.
best practise
change containerd’s default data path
Identify the Current Data Path
1
containerd config default | grep "root" # Expected output: root = "/var/lib/containerd"
Modify the following lines in /etc/containerd/config.toml:
1
root = "/path/to/new/data/path" # the location where container data (images, volumes) is stored
Move Existing Data (if required)
1
2
3sudo systemctl stop containerd # optional
sudo mv /var/lib/containerd /data/containerd
sudo systemctl start containerd
ctr
image
1 | list k8s image |
| Usage Context | Command |
|---|---|
| Default Namespace | ctr container ls |
| Kubernetes Namespace | ctr -n k8s.io container ls |
| Check Process PIDs | ctr task ls |
| Detailed Inspection | ctr container info <id> |
1 | list k8s running container |
nerdctl
Converting your Docker command to containerd requires using either ctr (low-level tool) or nerdctl (Docker-compatible CLI). I strongly recommend using nerdctl as ctr is designed for debugging and lacks many Docker features.
nerdctl provides a Docker-compatible interface and supports the features you need.
1 | list |
ctrctl
1 | VERSION="v1.34.0" |
command
1 | crictl images |
reference
Containerd daemon is the manager. It handles requests from kubelet and crictl. It does not run your apps itself.
Shim (containerd-shim-runc-v2) is a small helper process, one per pod. It starts the container, watches it, and keeps its logs and exit status.
Container is a normal Linux process (for example node-cache) running in isolated namespaces and cgroups. Its parent is the shim.
The chain is: kubelet → containerd daemon → shim → container process. The shim’s parent is PID 1, so it does not depend on the daemon staying alive.
KillMode
Restarting containerd makes systemd stop the old daemon first. KillMode decides who else gets killed with it.
| KillMode | Daemon | Shims and containers | Result |
|---|---|---|---|
process |
Killed | Kept running | Safe. Pods keep running |
control-group |
Killed | Killed | All pods on the node die |
mixed |
Killed (SIGTERM) | Killed (SIGKILL) | All pods on the node die |
none |
Not killed | Kept running | Not normally used |
Shims sit in the same systemd cgroup as the daemon. control-group and mixed kill everything in that cgroup, and process kills only the daemon.
Your node has KillMode=process, so a restart is safe. Check the setting on every node before you restart:
1 | systemctl show containerd -p KillMode |