crt task

1.[root@containerd busybox]# cd /root/busybox
2.利用containerd cli (/usr/local/bin/ctr)运行容器
[root@containerd busybox]# ctr run -t -d --rootfs rootfs busybox /bin/sh
[root@containerd busybox]# ctr container list
CONTAINER IMAGE RUNTIME
busybox - io.containerd.runtime.v1.linux
[root@containerd busybox]# ps -ef |grep container
root 9539 1 0 21:22 ? 00:00:03 /usr/local/bin/containerd
root 15285 9539 0 22:02 ? 00:00:00 containerd-shim -namespace default -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/default/busybox -address /run/containerd/containerd.sock -containerd-binary /usr/local/bin/containerd -debug
3.登录容器验证
[root@containerd busybox]# ctr tasks list
TASK PID STATUS
busybox 15301 RUNNING
[root@containerd busybox]# ctr tasks exec -t --exec-id 15301 busybox /bin/sh
/ # hostname
containerd
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
4.stop容器
[root@containerd busybox]# ctr tasks kill --signal 9 busybox
[root@containerd busybox]# ctr tasks list
TASK PID STATUS
busybox 15301 STOPPED
5.删除容器
[root@containerd busybox]# ctr container delete busybox
[root@containerd busybox]# ctr container list
CONTAINER IMAGE RUNTIME


原文地址:https://www.cnblogs.com/dream397/p/13842324.html