Skip to content

containerd ctr Command Error — Quick Fix

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about containerd ctr command error. We cover key concepts, practical examples, and best practices.

The Problem

The ctr command fails to pull images, list containers, or interact with containerd. The error may indicate a namespace issue, a connection failure to the containerd socket, or an image not found in the configured repository.

Error example:

ctr: failed to dial "/run/containerd/containerd.sock": connection refused
ctr: image not found
ctr: content digest not found: not found

The Fix

Step 1: Specify the correct namespace

WRONG — running ctr without specifying a namespace:

# ctr defaults to the "default" namespace
# Docker/Kubernetes use "moby" or "k8s.io"

RIGHT — use the correct namespace:

# List namespaces
ctr namespaces list

# Use the k8s.io namespace for Kubernetes-managed containers
ctr -n k8s.io images list

# Use moby namespace for Docker-managed containers
ctr -n moby containers list

Output:

REF                                TYPE   DIGEST
docker.io/library/nginx:latest     image  sha256:abc123

Step 2: Check the containerd socket

WRONG — assuming containerd is always listening on the default socket:

# The socket path may differ by distribution

RIGHT — verify the containerd socket exists:

ls -la /run/containerd/containerd.sock

Output:

srw-rw---- 1 root root 0 Jun 24 10:00 /run/containerd/containerd.sock

If the socket is missing, check if containerd is running:

systemctl status containerd
systemctl restart containerd

Use DodaTech's Container Runtime Monitor to check containerd socket health, namespace usage, and image cache statistics across all nodes.

Prevention Tips

  • Always specify -n k8s.io when running ctr on Kubernetes nodes
  • Use the --address flag if containerd listens on a custom socket path
  • Set the CONTAINERD_NAMESPACE environment variable to avoid forgetting the -n flag
  • Monitor containerd socket with systemd socket activation
  • Use DodaTech's CRI Diagnostics Tool for unified containerd and CRI-O troubleshooting

Common Mistakes with ctr error

  1. Using foldl instead of foldl' causing stack overflow on large lists
  2. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  3. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable

These mistakes appear frequently in real-world CONTAINERD code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does ctr show different images than docker?

ctr and docker use different namespaces by default. Docker stores images under the moby namespace, while ctr defaults to the default namespace. Use ctr -n moby images list to see Docker-managed images, or use docker image ls directly.

What is the difference between ctr and crictl?

ctr is containerd's native CLI with full access to all containerd features (including non-standard ones). crictl is the CRI-compatible CLI that works with any CRI-compliant runtime (containerd, CRI-O). For Kubernetes troubleshooting, prefer crictl over ctr.

How do I use ctr to pull images from a private registry?

Use ctr image pull --user username:password registry.example.com/image:tag. For TLS-enabled registries, ensure the CA certificate is in the system trust store, or use --skip-verify for testing only.

Related: DodaTech's Container Runtime Analyzer provides a unified interface across containerd, CRI-O, and Docker for image management and runtime diagnostics.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro