How to delete all containers and images in containerd?

Viewed 4498

I only have containerd installed, I'm using it for my k8s container runtime. I'm trying to clean up things. What might be the equivalent of the ff docker commands in containerd:

sudo docker rm -vf $(docker ps -a -q)
sudo docker rmi -f $(docker images -a -q)
1 Answers

To delete images:

ctr -n k8s.io i rm $(ctr -n k8s.io i ls -q | grep your_filter)

The arguments mean:

  • -n: namespace
  • i: image
  • ls: list
  • -q: show only ref

A similar command works for containers:

ctr -n k8s.io c rm $(ctr -n k8s.io c ls -q | grep your_filter)
Related