Core Concepts (Part 2)
Docker vs. containerd in Kubernetes: Architecture Evolution and CLI Tools (ctr, nerdctl, crictl)
Older Kubernetes tutorials reference Docker everywhere, while modern documentation focuses on containerd and tools like crictl or nerdctl. Understanding why that shift happened—and which CLI tool belongs in each workflow—eliminates one of the most common points of confusion when working on Kubernetes worker nodes.
1. How Kubernetes Evolved from Docker to containerd
Early Tight Coupling
When Kubernetes first launched, Docker was the dominant container platform thanks to its developer-friendly workflow. Kubernetes was built specifically to orchestrate Docker, hardcoding Docker integration directly into the kubelet.
CRI and OCI Standards
As Kubernetes grew, users wanted support for alternative runtimes (such as rkt and CRI-O). To avoid maintaining custom integrations for every runtime, Kubernetes introduced the Container Runtime Interface (CRI)—a plugin API allowing any compliant runtime to communicate with kubelet.
Alongside CRI, the Open Container Initiative (OCI) established two core industry specifications:
- Image Spec: Defines how container images are structured and packaged.
- Runtime Spec: Defines how a low-level runtime unpacks and executes a container on the host OS (implemented by
runc).
What Docker Actually Is Under the Hood
Docker is not a single monolithic runtime; it is a full developer platform layered over smaller components:
- Docker CLI & Docker API (developer commands, image building, networking, volumes, auth)
dockerd(the Docker Engine daemon)containerd(high-level container lifecycle daemon managing image transfers, storage, and supervision)runc(low-level OCI runtime that spawns the actual Linux container processes)
Because Docker predated CRI, dockerd did not implement the CRI specification. To keep Docker working, Kubernetes maintained Dockershim—a temporary translation layer inside kubelet that bridged CRI calls to the Docker API.
Kubernetes v1.24 and the Removal of Dockershim
Maintaining Dockershim created extra overhead and duplicated layers (kubelet → dockershim → dockerd → containerd → runc). Because containerd already implements CRI natively, Kubernetes removed dockershim in version 1.24.
Do Docker images still work on Kubernetes? Yes. Images built with
docker buildadhere to the OCI Image Spec.containerdpulls and runs Docker-built images natively without any changes to your registries or Dockerfiles.
2. Standalone containerd
containerd graduated from the Cloud Native Computing Foundation (CNCF) as an independent, industry-standard container runtime. On modern Kubernetes worker nodes, you install containerd directly without needing Docker Engine, removing unnecessary overhead while preserving full OCI compatibility.
3. Comparing ctr, nerdctl, and crictl
Without the docker CLI installed on a node, administrators interact with containers using three distinct command-line tools.
Feature | ctr | nerdctl | crictl |
Maintained By | containerd community | containerd community | Kubernetes community (SIG Node) |
Target Scope |
|
| Any CRI-compatible runtime ( |
Primary Purpose | Low-level runtime debugging | General-purpose container management | Kubernetes node & Pod troubleshooting |
Pod-Aware? | No (namespaces only) | Partial ( | Yes ( |
Production Use | Avoid for daily operations | Recommended Docker CLI replacement | Standard tool for Kubernetes debugging |
A. ctr (Low-Level containerd Debugging)
ctr ships bundled with containerd and talks directly to the containerd daemon. It exposes a minimal feature set intended strictly for debugging containerd internals rather than day-to-day administration.
# Pull an image using ctr (requires full registry path)
ctr images pull docker.io/library/redis:alpine
# Run a container
ctr run docker.io/library/redis:alpine my-redis
(Note: Because Kubernetes stores its containers inside the k8s.io namespace in containerd, running ctr containers list without -n k8s.io will return empty results on a Kubernetes node.)
B. nerdctl (Docker-Compatible CLI for containerd)
nerdctl is a user-friendly CLI for containerd designed as a drop-in replacement for the docker CLI. You can substitute docker with nerdctl in nearly any workflow—including nerdctl run, nerdctl build, nerdctl ps, and nerdctl compose.
Beyond Docker parity, nerdctl exposes cutting-edge containerd capabilities:
- Encrypted container images (OCIcrypt)
- Lazy pulling (eStargz) to start containers before full image downloads finish
- Peer-to-peer (P2P) image distribution and image signing/verification
# Run an Nginx container with port mapping just like Docker
nerdctl run -d -p 8080:80 --name web nginx:alpine
# Inspect Kubernetes-managed containers via the k8s.io namespace
nerdctl --namespace k8s.io ps
C. crictl (Kubernetes CRI Troubleshooting CLI)
crictl is built by the Kubernetes community to inspect and debug CRI-compatible runtimes from Kubernetes' point of view. Unlike ctr and nerdctl, crictl works identically whether your cluster runs containerd, CRI-O, or cri-dockerd, and it natively understands Pods.
# List all Pods on the local worker node
crictl pods
# List running containers
crictl ps
# View logs for a specific container
crictl logs <container-id>
# Execute an interactive shell inside a container
crictl exec -it <container-id> /bin/sh
Warning: Never use crictl to deploy application containers. kubelet continuously reconciles the node's state against the kube-apiserver. If you manually start a container or Pod using crictl, kubelet will detect an unrecognized workload and automatically delete it.
4. Extra Production Details Worth Knowing
- Configuring
crictlRuntime Endpoints (Kubernetes 1.24+): Afterdockershim.sockwas removed in v1.24,crictldeprecated automatic fallback endpoints. On modern nodes, configure/etc/crictl.yamlexplicitly so you don't receive socket deprecation warnings:
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
- What if you still need Docker Engine in Kubernetes 1.24+? Mirantis and Docker maintain
cri-dockerd, an external CRI adapter (unix:///var/run/cri-dockerd.sock) that allows organizations with hard dependencies on Docker Engine to continue running it alongside modern Kubernetes releases. - Local Development vs. Node Operations: On your local laptop, tools like Docker Desktop, Rancher Desktop, or Colima still provide a full
dockerCLI experience while usingcontainerdunder the hood—giving you the familiar developer UX locally and the streamlinedcontainerd+crictlstack in production.
Comments
Join the discussionNo comments yet. Be the first to comment.