Why Switch from Docker to containerd? A Quick Guide for Kubernetes Users
This article explains what containerd is, compares it with Docker, describes Kubernetes' CRI support, and provides step‑by‑step commands for using containerd via crictl, showing that migrating from Docker to containerd is simple and resource‑efficient.
containerd Introduction
containerd is an industrial‑grade container runtime that emphasizes simplicity, robustness and portability. It manages the full container lifecycle on the host, including image transfer and storage, execution, management, storage and networking.
Docker vs containerd
containerd was split out from Docker and can serve as a low‑level runtime; it is now the preferred runtime for Kubernetes.
Many cloud platforms also support containerd as the underlying runtime.
K8s CRI
Kubernetes defines the Container Runtime Interface (CRI) so any runtime that implements CRI can be used as the underlying runtime.
Why does K8s abandon Docker for containerd?
If Docker is used, kubelet must go through
dockershimto call Docker, which then calls containerd.
If containerd is used, its built‑in
CRIplugin allows kubelet to call containerd directly.
Using containerd improves performance (shorter call chain) and reduces resource consumption because Docker includes many extra features.
Using containerd
If you have used Docker, you can learn containerd in about five minutes.
In a previous article we installed K3s, which uses containerd by default; installing K3s gives you containerd.
Simply replace Docker commands with
crictlto operate containerd, e.g., list running containers.
<code>crictl ps</code> <code>CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
4ca73ded41bb6 3b0b04aa3473f Less than a second ago Running helm 20 21103f0058872
3bb5767a81954 296a6d5035e2d About a minute ago Running coredns 1 af887263bd869
a5e34c24be371 0346349a1a640 About a minute ago Running nginx 1 89defc6008501</code>List all images:
<code>crictl images</code> <code>IMAGE TAG IMAGE ID SIZE
docker.io/library/nginx 1.10 0346349a1a640 71.4MB
docker.io/rancher/coredns-coredns 1.8.0 296a6d5035e2d 12.9MB
docker.io/rancher/klipper-helm v0.4.3 3b0b04aa3473f 50.7MB
docker.io/rancher/local-path-provisioner v0.0.14 e422121c9c5f9 13.4MB
docker.io/rancher/metrics-server v0.3.6 9dd718864ce61 10.5MB
docker.io/rancher/pause 3.1 da86e6ba6ca19 327kB</code>Enter a container’s shell (use container ID):
<code>crictl exec -it a5e34c24be371 /bin/bash</code>Check resource usage, which is very low:
<code>crictl stats</code> <code>CONTAINER CPU % MEM DISK INODES
3bb5767a81954 0.54 14.27MB 254B 14
a5e34c24be371 0.00 2.441MB 339B 16</code>Conclusion
Switching from Docker to containerd is straightforward; just replace Docker commands with
crictl. Because both are from the same company, the usage is similar, so the deprecation of Docker in Kubernetes has little impact for developers.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.