• ctr images pull docker.io/library/redis:latest


     

    root@ubuntu:~# ctr images list | grep redis
    docker.io/library/redis:latest application/vnd.docker.distribution.manifest.list.v2+json sha256:33ca074e6019b451235735772a9c3e7216f014aae8eb0580d7e94834fe23efb3 35.1 MiB linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/mips64le,linux/ppc64le,linux/s390x -      
    root@ubuntu:~# ctr images list -q
    docker.io/library/redis:latest
    root@ubuntu:~# ctr images rm docker.io/library/redis:latest
    docker.io/library/redis:latest
    root@ubuntu:~# 

     

    containerd

    containerd is a high-level runtime that was split off from Docker. Like runc, which was broken off as the low-level runtime piece, containerd was broken off as the high-level runtime piece of Docker. containerd implements downloading images, managing them, and running containers from images. When it needs to run a container it unpacks the image into an OCI runtime bundle and shells out to runc to run it.

    Containerd also provides an API and client application that can be used to interact with it. The containerd command line client is ctr.

    ctr can be used to tell containerd to pull a container image:

    $ sudo ctr images pull docker.io/library/redis:latest
    

    List the images you have:

    $ sudo ctr images list
    

    Run a container based on an image:

    $ sudo ctr container create docker.io/library/redis:latest redis
    

    List the running containers:

    $ sudo ctr container list
    

    Stop the container:

    $ sudo ctr container delete redis
    

    These commands are similar to how a user interacts with Docker. However, in contrast with Docker, containerd is focused solely on running containers, so it does not provide a mechanism for building containers. Docker was focused on end-user and developer use cases, whereas containerd is focused on operational use cases, such as running containers on servers. Tasks such as building container images are left to other tools.

    containerd的加载方式:ctr命令方式

    在4个节点都把puase镜像加载进去

    [root@host121 data]# ctr --version
    ctr github.com/rancher/containerd v1.3.0-k3s.4 
    [root@host121 data]# ls
    pause-amd64-3.1.tar.gz
    [root@host121 data]# gunzip pause-amd64-3.1.tar.gz 
    [root@host121 data]# ls
    pause-amd64-3.1.tar
    [root@host121 data]# ctr images import pause-amd64-3.1.tar 
    unpacking gcr.io/google_containers/pause-amd64:3.1 (sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c)...done
    [root@host121 data]# ctr images list
    REF                                                                     TYPE                                       DIGEST                                                                  SIZE      PLATFORMS   LABELS                          
    gcr.io/google_containers/pause-amd64:3.1                                application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    sha256:da86e6ba6ca197bf6bc5e9d900febd906b133eaa4750e6bed647b0fbe50ed43e application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    [root@host121 data]# ctr images tag gcr.io/google_containers/pause-amd64:3.1 k8s.gcr.io/pause:3.1
    k8s.gcr.io/pause:3.1
    [root@host121 data]#

    确认一下,已经加载进来了

    [root@host121 data]# ctr images list
    REF                                                                     TYPE                                       DIGEST                                                                  SIZE      PLATFORMS   LABELS                          
    gcr.io/google_containers/pause-amd64:3.1                                application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    sha256:da86e6ba6ca197bf6bc5e9d900febd906b133eaa4750e6bed647b0fbe50ed43e application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    [root@host121 data]#

    但是名称还是不同,所以需要tag命令来帮助一下

    [root@host121 data]# ctr images tag gcr.io/google_containers/pause-amd64:3.1 k8s.gcr.io/pause:3.1
    k8s.gcr.io/pause:3.1
    [root@host121 data]# ctr images list
    REF                                                                     TYPE                                       DIGEST                                                                  SIZE      PLATFORMS   LABELS                          
    gcr.io/google_containers/pause-amd64:3.1                                application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    k8s.gcr.io/pause:3.1                                                    application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    sha256:da86e6ba6ca197bf6bc5e9d900febd906b133eaa4750e6bed647b0fbe50ed43e application/vnd.oci.image.manifest.v1+json sha256:0968e31df05b727234888883ba43ccaa4ec75566113c75065af5a6124b62d93c 729.0 KiB linux/amd64 io.cri-containerd.image=managed 
    [root@host121 data]# 
    

    ker的加载方式:ctr命令方式

    如果是Docker作为容器运行环境的情况,使用docker load -i命令将pause镜像加载进去即可。

    执行命令:docker load -i pause镜像名称

  • 相关阅读:
    基于JWT用户认证方式(前后端分离)
    git推送时报错:hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing
    (fields.E210) Cannot use ImageField because Pillow is not installed....解决方法
    python3.6报错:AttributeError: 'str' object has no attribute 'decode'
    于在Python3.6.7 +Ubuntu16.04下安装channels报错
    docsify 搭建优雅项目文档
    SQLSERVER 系统表查询
    数据立方建立-如何实现一对多,多对多
    从BI分析角度,数据立方的建立方法
    MYSQL库内所有表名及表结构获取
  • 原文地址:https://www.cnblogs.com/dream397/p/13819153.html
Copyright © 2020-2023  润新知