kubernetes:crictl

CRI(Container Runtime Interface)

# 소켓 명시
crictl --runtime-endpoint unix:///run/containerd/containerd.sock <cmd>
 
# 또는 /etc/crictl.yaml 설정
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false
# 특정 k8s namespace의 pod 조회
crictl pods --namespace kube-system
 
# pod id로 컨테이너 찾기
crictl ps --pod <pod-id>
 
# 컨테이너 로그 + exec 콤보
crictl logs -f $(crictl ps --name nginx -q)
crictl exec -it $(crictl ps --name nginx -q) sh
 
# 죽은 컨테이너 정리
crictl ps -a | grep Exited | awk '{print $1}' | xargs crictl rm
 
# 이미지 전체 정리 (사용 중인 것 제외하고 자동)
crictl rmi --prune
  • crictl pods pod 목록
    • –name name: 이름 필터
    • –namespace namespace: k8s namespace 필터
    • –label key=value
  • crictl inspectp pod_id pod 상세(JSON)
  • crictl stopp pod_id pod 중지
  • crictl rmp pod_id pod 삭제
  • crictl ps 실행 중인 컨테이너
    • -a: 전체(종료 포함)
    • –name name
    • –pod pod_id
    • –label key=value
  • crictl inspect container_id 컨테이너 상세
  • crictl start container_id
  • crictl stop container_id
    • –timeout time 종료시간
  • crictl rm container_id
    • –force, -f
  • crictl exec container_id cmd
    • -it tty interactive
  • crictl attach container_id
  • crictl logs container_id
    • -f follow
    • –tail line
    • –since 1h 1h
    • –timestamps
  • crictl images 이미지 목록
    • –digests
  • crictl pull image pull
    • –creds user:pass
  • crictl inspecti image 이미지 상세
  • crictl rmi image 이미지 삭제
  • crictl imagefsinfo 이미지 파일 시스템 정보
  • crictl stats 컨테이너 리소스 사용량
    • -a 모두(중지포함)
  • crictl statsp pod 단위 stats (v1.26+)
  • crictl info 런타임 전체 저보
  • crictl version 버전 정보
  • crictl config –list 현재 critl 설정
  • crictl runp pod-config.json pod 직접 생성
  • crictl create po_id container-config.json pod-config.json 컨테이너 직접 실행
pod-config.json
{
  "metadata": { "name": "debug-pod", "namespace": "default" },
  "log_directory": "/tmp",
  "linux": {}
}

crictl --help

  • /home/u613600155/domains/cli.zerotymer.net/public_html/data/pages/kubernetes/crictl.txt
  • 마지막으로 수정됨: 2026/02/25 08:54
  • 저자 writer