A quick reference for crictl โ the Kubernetes CRI debugging tool. Bookmark this page.
Container Operations
# List containers
crictl ps # Running
crictl ps -a # All (including stopped)
crictl ps -o json # JSON output
# Inspect container
crictl inspect CONTAINER_ID
# View logs
crictl logs CONTAINER_ID
crictl logs -f CONTAINER_ID # Follow
crictl logs --tail 50 CONTAINER_ID # Last 50 lines
# Execute command in container
crictl exec -it CONTAINER_ID sh
# Stop and remove
crictl stop CONTAINER_ID
crictl rm CONTAINER_IDPod Operations
# List pods
crictl pods
crictl pods --name nginx # Filter by name
crictl pods --state Ready # Filter by state
# Inspect pod
crictl inspectp POD_ID
# Stop and remove pod
crictl stopp POD_ID
crictl rmp POD_IDImage Operations
# List images
crictl images
crictl images -o json
# Pull image
crictl pull nginx:alpine
# Inspect image
crictl inspecti nginx:alpine
# Remove image
crictl rmi nginx:alpine
# Remove unused images
crictl rmi --pruneRuntime Info
# Show runtime info
crictl info
# Show runtime version
crictl version
# Show container stats
crictl stats
crictl stats CONTAINER_IDConfiguration
# /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: falseTroubleshooting Kubernetes
# Find container for a pod
crictl ps --name my-pod
# Check why a pod is failing
crictl pods --state NotReady
crictl logs $(crictl ps -a --name failing-container -q)
# Check image pull issues
crictl pull image:tag 2>&1
# Clean up stopped containers
crictl rm $(crictl ps -a -q --state Exited)Tips and Tricks
- Set
runtime-endpointin/etc/crictl.yamlto avoid passing-revery time - Use
crictlfor Kubernetes debugging,ctrfor containerd-level operations - Use
-o yamlor-o jsonfor scripting crictl statsshows real-time CPU/memory per container