DEV Community

Alex Spinov
Alex Spinov

Posted on

containerd Has a Free API: The Industry-Standard Container Runtime

Why containerd

containerd is the container runtime that Docker and Kubernetes use under the hood. It manages the complete container lifecycle — image pull, create, start, snapshot, network, stop.

Install

# Already included in Docker Desktop and most K8s distributions
# Standalone install:
curl -LO https://github.com/containerd/containerd/releases/latest/download/containerd-static-linux-amd64.tar.gz
tar -xf containerd-static-linux-amd64.tar.gz -C /usr/local

# CLI
brew install nerdctl
Enter fullscreen mode Exit fullscreen mode

nerdctl (Docker-Compatible CLI)

# Pull image
nerdctl pull nginx:latest

# Run container
nerdctl run -d -p 8080:80 --name web nginx

# List containers
nerdctl ps

# Build image
nerdctl build -t myapp:latest .

# Compose
nerdctl compose up -d
Enter fullscreen mode Exit fullscreen mode

ctr (Low-Level CLI)

# Pull image
ctr images pull docker.io/library/nginx:latest

# List images
ctr images list

# Run container
ctr run -d docker.io/library/nginx:latest web

# Namespaces
ctr namespaces list
Enter fullscreen mode Exit fullscreen mode

containerd API (Go)

import "github.com/containerd/containerd"

client, _ := containerd.New("/run/containerd/containerd.sock")
image, _ := client.Pull(ctx, "docker.io/library/nginx:latest")
container, _ := client.NewContainer(ctx, "web",
    containerd.WithNewSnapshot("web-snapshot", image),
    containerd.WithNewSpec(oci.WithImageConfig(image)),
)
task, _ := container.NewTask(ctx, cio.NewCreator())
task.Start(ctx)
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Industry standard — Docker, K8s, cloud providers
  • OCI compliant — standard container images and runtimes
  • Snapshots — efficient filesystem management
  • Namespaces — multi-tenant isolation
  • CRI plugin — native Kubernetes integration
  • CNCF Graduated — production foundation

Resources


Need to extract container runtime data, image metadata, or registry info? Check out my Apify tools or email spinov001@gmail.com for custom solutions.

Top comments (0)