Containerd容器管理( 二 )

.
Commercial support is available atnginx.com.

Thank you for using nginx.

暂停容器进程和 docker pause 类似的功能:
[root@localhost ~]# ctr task pause nginx暂停后容器状态变成了 PAUSED:
[root@localhost ~]# ctr task lsTASKPIDSTATUSnginx22945PAUSED恢复容器进程使用 resume 命令来恢复容器:
【Containerd容器管理】[root@localhost ~]# ctr task resume nginx [root@localhost ~]# ctr task lsTASKPIDSTATUSnginx22945RUNNING杀死容器进程ctr 没有 stop 容器的功能,只能暂停或者杀死容器进程,然后在删除容器杀死容器进程可以使用 task kill 命令:
[root@localhost ~]# ctr task kill nginx[root@localhost ~]# ctr task lsTASKPIDSTATUSnginx22945STOPPED删除进程杀掉容器后可以看到容器的状态变成了 STOPPED 。同样也可以通过 task rm 命令删除 Task:
[root@localhost ~]# ctr task rm nginx[root@localhost ~]# ctr task lsTASKPIDSTATUS删除进程之后才可以删除容器:
[root@localhost ~]# ctr c rm nginx查看容器进程资源除此之外我们还可以获取容器的 cgroup 相关信息,可以使用 task metrics 命令用来获取容器的内存、CPU 和 PID 的限额与使用量 。
# 重新启动容器[root@localhost ~]# ctr task start -d nginx[root@localhost ~]# ctr task metrics nginxIDTIMESTAMPnginxseconds:1701925304nanos:694970440METRICVALUEmemory.usage_in_bytes2592768memory.limit_in_bytes9223372036854771712memory.stat.cache258048cpuacct.usage21976291cpuacct.usage_percpu[21976291 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]pids.current2pids.limit0



推荐阅读