← 返回命令列表

Linux command

crictl 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List containers

crictl ps

List all containers including stopped

crictl ps -a

List images

crictl images

Pull image

crictl pull [image:tag]

Run pod from config

crictl runp [pod.json]

Create container

crictl create [pod-id] [container.json] [pod.json]

Start container

crictl start [container-id]

Execute command in container

crictl exec -it [container-id] [/bin/sh]

View container logs

crictl logs [container-id]

Remove container

crictl rm [container-id]

Stop and remove pod

crictl stopp [pod-id] && crictl rmp [pod-id]

说明

crictl is a command-line interface for CRI-compatible container runtimes. CRI (Container Runtime Interface) is the plugin interface that enables Kubernetes to work with different container runtimes. crictl provides debugging and inspection tools for Kubernetes nodes, interacting directly with containerd, CRI-O, or other CRI-compliant runtimes. Unlike docker or podman which are designed for general container management, crictl is specifically built for Kubernetes troubleshooting. It exposes the CRI API operations, allowing cluster administrators to inspect pod sandboxes, containers, and images as they exist in the CRI runtime layer, helping diagnose issues with pod scheduling, container creation, and image pulling.

参数

-r, --runtime-endpoint _endpoint_
CRI runtime endpoint (e.g., unix:///run/containerd/containerd.sock).
-i, --image-endpoint _endpoint_
CRI image endpoint.
--timeout _duration_
Connection timeout in seconds (default: 2).
--config _path_
Location of the client config file (default: /etc/crictl.yaml).
-D, --debug
Enable debug output.

FAQ

What is the crictl command used for?

crictl is a command-line interface for CRI-compatible container runtimes. CRI (Container Runtime Interface) is the plugin interface that enables Kubernetes to work with different container runtimes. crictl provides debugging and inspection tools for Kubernetes nodes, interacting directly with containerd, CRI-O, or other CRI-compliant runtimes. Unlike docker or podman which are designed for general container management, crictl is specifically built for Kubernetes troubleshooting. It exposes the CRI API operations, allowing cluster administrators to inspect pod sandboxes, containers, and images as they exist in the CRI runtime layer, helping diagnose issues with pod scheduling, container creation, and image pulling.

How do I run a basic crictl example?

Run `crictl ps` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -r, --runtime-endpoint _endpoint_ do in crictl?

CRI runtime endpoint (e.g., unix:///run/containerd/containerd.sock).