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鏡像名稱

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM