1、安装
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install containerd
containerd config default > /etc/containerd/config.toml
systemctl enable containerd.service
systemctl start containerd.service
2、替换 containerd 默认的sand_box镜像
#替换默认pause镜像
sed -i 's/k8s.gcr.io\/pause:3.2/registry.baidubce.com\/k8s.gcr.io\/pause:3.2/g' /etc/containerd/config.toml
#修改默认Cgroup驱动
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
#配置镜像加速器
systemctl daemon-reload
systemctl restart containerd
1、创建容器
#下载nginx镜像
ctr -n k8s.io i pull docker.io/library/nginx:latest
#创建一个container
ctr -n k8s.io container create docker.io/library/nginx:latest nginx
#创建一个task
ctr -n k8s.io task start -d nginx
ctr -n k8s.io task ls
#精简版命令
ctr -n k8s.io run -d docker.io/library/nginx:latest nginx02
#查看containerd在宿主机的pid
ctr -n k8s.io task ls
TASK PID STATUS
nginx02 4755 RUNNING
ps ajxf|grep "containerd-shim-runc\|4755"|grep -v grep
2、查看并进入容器
ctr -n k8s.io container ls
ctr -n k8s.io t exec --exec-id $RANDOM -t nginx02 sh
3、发送SIGKILL信号量杀死该容器
ctr -n k8s.io t kill -s SIGKILL nginx02
ctr -n k8s.io container rm nginx02
4、清理未被容器引用的镜像
crictl rmi --prune