# Core Concepts (Part 2)

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:

1. **Docker CLI & Docker API** (developer commands, image building, networking, volumes, auth)
2. `dockerd` (the Docker Engine daemon)
3. `containerd` (high-level container lifecycle daemon managing image transfers, storage, and supervision)
4. `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.

![](https://cdn.hashnode.com/uploads/covers/6487014233d44005d5894e2b/a2d66150-ecc5-4d0e-ab4c-c327af55ad5b.png align="center")

### 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 build` adhere to the **OCI Image Spec**. `containerd` pulls 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.

<table style="min-width: 100px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1"><p><strong>Feature</strong></p></td><td colspan="1" rowspan="1"><p><strong>ctr</strong></p></td><td colspan="1" rowspan="1"><p><strong>nerdctl</strong></p></td><td colspan="1" rowspan="1"><p><strong>crictl</strong></p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Maintained By</strong></p></td><td colspan="1" rowspan="1"><p>containerd community</p></td><td colspan="1" rowspan="1"><p>containerd community</p></td><td colspan="1" rowspan="1"><p>Kubernetes community (SIG Node)</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Target Scope</strong></p></td><td colspan="1" rowspan="1"><p><code>containerd</code> only</p></td><td colspan="1" rowspan="1"><p><code>containerd</code> only</p></td><td colspan="1" rowspan="1"><p><strong>Any CRI-compatible runtime</strong> (<code>containerd</code>, <code>CRI-O</code>)</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Primary Purpose</strong></p></td><td colspan="1" rowspan="1"><p>Low-level runtime debugging</p></td><td colspan="1" rowspan="1"><p>General-purpose container management</p></td><td colspan="1" rowspan="1"><p>Kubernetes node &amp; Pod troubleshooting</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Pod-Aware?</strong></p></td><td colspan="1" rowspan="1"><p>No (namespaces only)</p></td><td colspan="1" rowspan="1"><p>Partial (<code>nerdctl --namespace </code><a target="_self" rel="noopener noreferrer nofollow" class="cursor-pointer" href="http://k8s.io" style="pointer-events: none;"><code>k8s.io</code></a>)</p></td><td colspan="1" rowspan="1"><p><strong>Yes</strong> (<code>crictl pods</code>)</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Production Use</strong></p></td><td colspan="1" rowspan="1"><p>Avoid for daily operations</p></td><td colspan="1" rowspan="1"><p>Recommended Docker CLI replacement</p></td><td colspan="1" rowspan="1"><p>Standard tool for Kubernetes debugging</p></td></tr></tbody></table>

### 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.

```plaintext
# 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`](http://k8s.io) namespace in `containerd`, running `ctr containers list` without `-n` [`k8s.io`](http://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

```plaintext
# 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**.

```plaintext
# 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** `crictl` **Runtime Endpoints (Kubernetes 1.24+):** After `dockershim.sock` was removed in v1.24, `crictl` deprecated automatic fallback endpoints. On modern nodes, configure `/etc/crictl.yaml` explicitly so you don't receive socket deprecation warnings:

```yaml
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 `docker` CLI experience while using `containerd` under the hood—giving you the familiar developer UX locally and the streamlined `containerd` + `crictl` stack in production.
