Containerd-1.6.5 镜像容器操作( 二 )

[root@ecs-65685 xyz]# ls[root@ecs-65685 xyz]# ctr i ls -qdocker.io/library/nginx:alpine[root@ecs-65685 xyz]# ctr i export --all-platforms nginx.tar docker.io/library/nginx:alpine[root@ecs-65685 xyz]# ctr i export nginx_i4t.com.tar docker.io/library/nginx:alpine[root@ecs-65685 xyz]# lsnginx_i4t.com.tarnginx.tar[root@ecs-65685 xyz]#[root@ecs-65685 xyz]# ctr i rm docker.io/library/nginx:alpinedocker.io/library/nginx:alpine[root@ecs-65685 xyz]# ctr i import nginx.tarunpacking docker.io/library/nginx:alpine (sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74)...done[root@ecs-65685 xyz]# ctr i ls -qdocker.io/library/nginx:alpine二、Containerd 容器操作1 基本参数
[root@ecs-65685 ~]# ctr c create -hNAME:ctr containers create - create containerUSAGE:ctr containers create [command options] [flags] Image|RootFS CONTAINER [COMMAND] [ARG...]OPTIONS:--snapshotter valuesnapshotter name. Empty value stands for the default value. [$CONTAINERD_SNAPSHOTTER]--snapshotter-label valuelabels added to the new snapshot for this container.--config value, -c valuepath to the runtime-specific spec config file--cwd valuespecify the working directory of the process--env valuespecify additional container environment variables (e.g. FOO=bar)--env-file valuespecify additional container environment variables in a file(e.g. FOO=bar, one per line)--label valuespecify additional labels (e.g. foo=bar)--mount valuespecify additional container mount (e.g. type=bind,src=https://www.huyubaike.com/tmp,dst=/host,options=rbind:ro)--net-hostenable host networking for the container--privilegedrun privileged container--read-onlyset the containers filesystem as readonly--runtime valueruntime name (default:"io.containerd.runc.v2")--runtime-config-path valueoptional runtime config path--tty, -tallocate a TTY for the container--with-ns valuespecify existing Linux namespaces to join at container runtime (format '<nstype>:<path>')--pid-file valuefile path to write the task's pid--gpus valueadd gpus to the container--allow-new-privsturn off OCI spec's NoNewPrivileges feature flag--memory-limit valuememory limit (in bytes) for the container (default: 0)--device valuefile path to a device to add to the container; or a path to a directory tree of devices to add to the container--cap-add valueadd Linux capabilities (Set capabilities with 'CAP_' prefix)--cap-drop valuedrop Linux capabilities (Set capabilities with 'CAP_' prefix)--seccompenable the default seccomp profile--seccomp-profile valuefile path to custom seccomp profile. seccomp must be set to true, before using seccomp-profile--apparmor-default-profile valueenable AppArmor with the default profile with the specified name, e.g. "cri-containerd.apparmor.d"--apparmor-profile valueenable AppArmor with an existing custom profile--rdt-class valuename of the RDT class to associate the container with. Specifies a Class of Service (CLOS) for cache and memory bandwidth management.--rootfsuse custom rootfs that is not managed by containerd snapshotter--no-pivotdisable use of pivot-root (linux only)--cpu-quota valueLimit CPU CFS quota (default: -1)--cpu-period valueLimit CPU CFS period (default: 0)--rootfs-propagation valueset the propagation of the container rootfs2 创建一个nginx容器

  • -n 指定命名空间
  • c 是简写 containers, c, container   manage containers
  • create 创建容器
  • --net-host 使用宿主机网络
  • docker.io/xx/xxx:xxx 镜像地址
  • nginx 容器名称
ctr -n xyz c create --net-host docker.io/library/nginx:alpine nginx3 查看容器列表
[root@ecs-65685 ~]# ctr -n xyz c lsCONTAINERIMAGERUNTIMEnginxdocker.io/library/nginx:alpineio.containerd.runc.v2nginx1docker.io/library/nginx:alpineio.containerd.runc.v24 只获取容器名称
[root@ecs-65685 ~]# ctr -n xyz c ls -qnginxnginx15 通过info参数查看容器的相关信息(类似于 docker inspect 功能)

经验总结扩展阅读