使用ctr操作containerd

  1. 查看版本
[root@k8s-image ~]# ctr version
Client:
  Version:  v1.5.4
  Revision: 69107e47a62e1d690afa2b9b1d43f8ece3ff4483
  Go version: go1.16.6

Server:
  Version:  v1.5.4
  Revision: 69107e47a62e1d690afa2b9b1d43f8ece3ff4483
  UUID: c1159e3c-61a7-4d75-81a7-e9773e01800b
  1. 创建namespace
[root@k8s-image ~]# ctr ns create jwdlh
[root@k8s-image ~]# ctr ns ls
NAME    LABELS 
default        
jwdlh 
  1. 拉镜像
[root@k8s-image ~]# ctr -n jwdlh i pull docker.io/library/nginx:latest
[root@k8s-image ~]# ctr -n jwdlh i ls
REF                            TYPE                                                      DIGEST                                                                  SIZE     PLATFORMS                                                                                               LABELS 
docker.io/library/nginx:latest application/vnd.docker.distribution.manifest.list.v2+json sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31 54.1 MiB linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/mips64le,linux/ppc64le,linux/s390x -      
  1. 启动容器并查看
[root@k8s-image ~]# ctr -n jwdlh run -d docker.io/library/nginx:latest  nginx-7
[root@k8s-image ~]# 
[root@k8s-image ~]# ctr -n jwdlh i ls
REF                            TYPE                                                      DIGEST                                                                  SIZE     PLATFORMS                                                                                               LABELS 
docker.io/library/nginx:latest application/vnd.docker.distribution.manifest.list.v2+json sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31 54.1 MiB linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/mips64le,linux/ppc64le,linux/s390x - 
[root@k8s-image ~]# 
[root@k8s-image ~]# ctr -n jwdlh c ls
CONTAINER    IMAGE                             RUNTIME                  
nginx-7      docker.io/library/nginx:latest    io.containerd.runc.v2    
[root@k8s-image ~]# ctr -n jwdlh t ls
TASK       PID      STATUS    
nginx-7    27131    RUNNING
  1. ctr run这个命令相当于做了两个步骤
    (1)ctr c create
    (2)ctr t start

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注