1、Containerd安装
先安装yum-utils工具
yum install -y yum-utils 配置Docker官方的yum仓库,如果做过,可以跳过
yum-config-manager
--add-repo
https://download.docker.com/linux/centos/docker-ce.repo安装containerd
yum install containerd.io -y启动服务
systemctl enable containerd
systemctl start containerd2、crictl命令用法
1、镜像相关
| 镜像相关功能 | Docker | Containerd |
|---|---|---|
| 显示本地镜像列表 | docker images | crictl images |
| 下载镜像 | docker pull | crictl pull |
| 上传镜像 | docker push | 无,例如buildk |
| 删除本地镜像 | docker rmi | crictl rmi |
| 查看镜像详情 | docker inspect IMAGE-ID | crictl inspecti IMAGE-ID |
2、容器相关
| 容器相关功能 | 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 |
3、pod相关
| POD 相关功能 | Docker | Containerd |
|---|---|---|
| 显示 POD 列表 | 无 | crictl pods |
| 查看 POD 详情 | 无 | crictl inspectp |
| 运行 POD | 无 | crictl runp |
| 停止 POD | 无 | crictl stopp |
3、ctr命令用法
Ctr就是containerd的命令行工具,可以用来执行和管理containerd中的任务。ctr主要用于开发和调试,而不是在生产环境中使用。
常见用法如下
查看containerd版本
$ ctr version拉取镜像
$ ctr images pull docker.io/library/busybox:latest #其中images可以简写为i列出本地镜像
$ ctr images list
#或者简写
$ ctr i ls修改tag
$ ctr i tag docker.io/library/busybox:latest busybox:latest删除镜像
$ ctr i rm docker.io/library/busybox:latest运行容器
$ ctr run -d busybox:latest busybox列出运行的容器
$ ctr containers list
#或者简写为
$ ctr c ls列出任务
$ ctr tasks ls
#或者简写
$ ctr t ls容器里执行命令
$ ctr t exec --exec-id 1860 busybox ls #1860为任务ID进入容器内部
$ ctr t exec -t --exec-id 1860 busybox sh删除容器
$ ctr t kill -s SIGKILL busybox #先杀掉进程
$ ctr c rm busybox #再删除容器Containerd有命名空间的概念,所以ctr可以指定命名空间
$ ctr -n k8s.io i ls #-n后面指定命名空间,k8s.io是k8s集群用的命名空间声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
