Skip to content

containerd Namespace Error — Quick Fix

DodaTech Updated 2026-06-24 2 min read

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

The Problem

Creating, deleting, or interacting with containerd namespaces fails. The namespace may not appear when listing, or operations against a namespace return "not found" errors. Kubernetes namespaces (k8s.io) may not be visible to ctr.

Error example:

ctr: namespace "k8s.io" not found
ctr: unable to delete namespace: namespace must be empty
ctr: failed to create namespace: invalid label

The Fix

Step 1: List and verify namespaces

WRONG — assuming namespaces are always visible:

# Namespaces must exist before you can use them

RIGHT — list all namespaces:

ctr namespaces list

Output:

default
k8s.io
moby

If the namespace you need is not listed, create it:

ctr namespaces create k8s.io

Step 2: Delete a namespace with content

WRONG — trying to delete a namespace with active content:

# containerd prevents deletion of non-empty namespaces

RIGHT — remove all content first, then delete:

# Remove all images in the namespace
ctr -n default images rm $(ctr -n default images list -q)

# Remove all containers in the namespace
ctr -n default containers rm $(ctr -n default containers list -q)

# Then delete the namespace
ctr namespaces rm default

Use DodaTech's Namespace Cleanup Tool to identify stale namespaces and safely remove their contents.

Prevention Tips

  • Use descriptive namespace names that match the orchestrator (k8s.io, moby)
  • Never delete namespaces with active pull operations
  • Set the CONTAINERD_NAMESPACE environment variable to avoid namespace confusion
  • Monitor namespace sizes to detect orphaned resources
  • Use DodaTech's Container Registry Inventory to track namespace usage

Common Mistakes with ns error

  1. Mixing let bindings with <- bindings in do notation, producing type errors
  2. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  3. Non-exhaustive pattern matches that compile with warnings then crash at runtime

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 not show the k8s.io namespace on my Kubernetes node?

The k8s.io namespace is created automatically when kubelet starts using containerd. If it is missing, check that containerd is configured as the CRI runtime and that kubelet has started successfully. Restart kubelet if necessary.

What happens if I delete a namespace that Kubernetes is using?

Kubernetes will lose track of all images and containers in that namespace, which may cause pods to fail or become orphaned. Never delete the k8s.io namespace while Kubernetes is running. If it happens accidentally, restart kubelet and all pods.

Can two namespaces contain images with the same name?

Yes. Namespaces provide isolation within containerd. You can have k8s.io/nginx:latest and default/nginx:latest as separate images with different digests. This allows orchestrators to manage images without conflicting with manual ctr operations.

Related: DodaTech's Runtime Troubleshooting Guide covers namespace management, image garbage collection, and content lifecycle across containerd and CRI-O.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro