换到 containerd 之后,节点上排查容器得用 crictl。命令和 docker 不完全一样,记住几个常用的就够。
对照
docker ps -> crictl ps docker ps -a -> crictl ps -a docker images -> crictl images docker logs 容器 -> crictl logs 容器ID docker exec -it 容器 -> crictl exec -it 容器ID sh docker inspect 容器 -> crictl inspect 容器ID docker stats -> crictl stats
先配 endpoint
cat > /etc/crictl.yaml <不配这个,直接报 connect: no such file or directory。
按 Pod 找容器
crictl pods crictl ps -p Pod沙箱IDcrictl pods 列出的是 sandbox(pause 容器),crictl ps 是业务容器。
拉镜像
crictl pull nginx:1.24 crictl rmi 镜像ID节点上手动拉镜像排查拉取问题很好用,比改 yaml 快。