最近更新时间:2023-03-29 16:28:05
容器运行时(Container Runtime)是kubernetes最重要的组件之一,负责管理镜像和容器的生命周期。Kubelet通过Container Runtime Interface (CRI) 与容器运行时交互,来管理镜像和容器。
容器服务目前提供Containerd和Docker两种运行时,您可根据集群Kubernetes版本和实际需求选择不同的运行时:
说明:Containerd 不支持 docker API 和 docker CLI,若您有该需求,可以通过 cri-tool 命令实现类似的功能。
| 命令 | Docker | Containerd |
|---|---|---|
| 查看镜像列表 | docker images | crictl images |
| 下载镜像 | docker pull | crictl pull |
| 上传镜像 | docker push | - |
| 删除镜像 | docker rmi | crictl rmi |
| 查看镜像详情 | docker inspect | crictl inspect |
| 命令 | Docker | Containerd |
|---|---|---|
| 查看容器列表 | docker ps | crictl ps |
| 创建容器 | docker create | crictl create |
| 启动容器 | docker start | crictl start |
| 停止容器 | docker stop | crictl stop |
| 删除容器 | docker rm | crictl rm |
| 查看容器详情 | docker inspect | crictl inspect |
| 挂载容器 | docker attach | crictl attach |
| 容器内执行命令 | docker exec | crictl exec |
| 查看容器日志 | docker logs | crictl logs |
| 显示容器资源使用情况 | docker stats | crictl stats |
| 命令 | Docker | Containerd |
|---|---|---|
| 查看pod列表 | - | crictl pods |
| 查看pod详情 | - | crictl inspectp |
| 运行pod | - | crictl runp |
| 停止pod | - | crictl stopp |
| 容器运行时 | 调用链 |
|---|---|
| Docker | kubelet -> docker shim -> dockerd -> containerd -> containerd-shim -> runC容器 |
| Containerd | kubelet -> containerd -> containerd-shim -> runC容器 |
纯净模式
