# List images
k3s crictl images
# Remove unused images
k3s crictl rmi --prune
# Remove specific image
k3s crictl rmi <image-id># List all containers (including stopped)
k3s crictl ps -a
# Remove stopped containers
k3s crictl rm $(k3s crictl ps -a -q --state exited)# List pods
k3s crictl pods
# Remove stopped pods
k3s crictl rmp $(k3s crictl pods -q --state ready=false)# Remove all unused containers, images, and cache
k3s crictl rmi --prune# Check log sizes
du -sh /var/log/containers/*
du -sh /var/log/pods/*
# Truncate large logs
truncate -s 0 /var/log/containers/*.log# Check k3s storage usage
du -sh /var/lib/rancher/k3s/*
# Containerd content store (largest usually)
du -sh /var/lib/rancher/k3s/agent/containerd/# Delete completed/failed pods
k3s kubectl delete pods --field-selector=status.phase==Succeeded -A
k3s kubectl delete pods --field-selector=status.phase==Failed -A
# Delete evicted pods
k3s kubectl get pods -A | grep Evicted | awk '{print $2 " -n " $1}' | xargs -L1 k3s kubectl delete podK3s runs containerd GC automatically. To tune it, edit /etc/rancher/k3s/config.yaml:
kubelet-arg:
- "image-gc-high-threshold=85"
- "image-gc-low-threshold=80"Restart after changes:
systemctl restart k3s