containerd常用命令

查看镜像

~]# ctr images list 或 ctr i ls

如没有指定名称空间则需指定

~]# ctr namespaces list 或 ctr ns list
NAME LABELS
k8s.io
~]# ctr -n k8s.io images list

镜像标记

~]# ctr -n k8s.io images tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2 k8s.gcr.io/pause:3.2

删除镜像

~]# ctr -n k8s.io images rm k8s.gcr.io/pause:3.2

拉取镜像

~]# ctr -n k8s.io images pull -k k8s.gcr.io/pause:3.2

导出镜像

~]# ctr -n k8s.io images export pause.tar k8s.gcr.io/pause:3.2

导入镜像;不支持 build,commit 镜像

~]# ctr -n k8s.io i import pause.tar

运行容器

~]# ctr -n k8s.io run --null-io --net-host -d –env PASSWORD=$drone_password –mount type=bind,src=/etc,dst=/host-etc,options=rbind:rw –mount type=bind,src=/root/.kube,dst=/root/.kube,options=rbind:rw $image sysreport bash /sysreport/run.sh
–null-io: 将容器内标准输出重定向到/dev/null
–net-host: 主机网络
-d: 当task执行后就进行下一步shell命令,如没有选项,则会等待用户输入,并定向到容器内

查看容器

~]# ctr containers list 或 ctr c ls

如没有指定名称空间则需指定

~]# ctr -n k8s.io c ls

先找出容器然后搜索容器名

~]# ctr -n k8s.io c ls
CONTAINER IMAGE RUNTIME
06…86 pause:3.2 io.containerd.runc.v2

找出容器名

~]# ctr -n k8s.io tasks list

停止容器

~]# kill -a -s 9 {id}

猜你喜欢

转载自blog.csdn.net/zhanremo3062/article/details/131678754