CKA系列-3.nerdctl镜像管理
2022/12/12 14:17 投稿
本文档采用的系统为:CentOS Linux release 7.4.1708 (Core)
课程来自于: 老段工作室 https://www.rhce.cc/
镜像的命名方式
仓库地址/分类/镜像名:tag
拉取镜像
nerdctl pull nginx #nerdctl pull 镜像 #默认是从dockerhub #https://hub.docker.com/
nerdctl pull hub.c.163.com/library/centos
nerdctl pull busybox
对于nerdctl来说,(nerdctl images)他在显示 除了default命名空间之外的其他命名空间里的镜像的时候,显示的结果不够友好,建议查看镜像的时候,使用crictl images
[root@vms71 yum.repos.d]# nerdctl pull hub.c.163.com/library/nginx
hub.c.163.com/library/nginx:latest: resolved |++++++++++++++++++++++++++++++++++++++|
layer-sha256:0af1f0713557eef77f3da5679951cdc516cf05b92362d4e4dc1c0a4233f8ce4e: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:5de4b4d551f8df95703aca8657fbbf2d8b21833d3f9b2b627d36d02745ad811d: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d4b36a5e9443715c0ff0c79903e28782504ebfbb66f00d4e965b86519dca9b30: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 7.3 s total: 41.2 M (5.6 MiB/s)
[root@vms71 yum.repos.d]# nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
hub.c.163.com/library/nginx latest 8eeb06742b41 56 seconds ago linux/amd64 113.3 MiB 41.2 MiB
<none> <none> 8eeb06742b41 56 seconds ago linux/amd64 113.3 MiB 41.2 MiB
[root@vms71 yum.repos.d]# crictl images
IMAGE TAG IMAGE ID SIZE
hub.c.163.com/library/nginx latest e5bc191dff1f9 43.2MB
nerdctl tag 给镜像打标签
[root@vms71 yum.repos.d]# nerdctl tag hub.c.163.com/library/nginx 192.168.26.71/nginx:v1
[root@vms71 yum.repos.d]# crictl images
IMAGE TAG IMAGE ID SIZE
192.168.26.71/nginx v1 e5bc191dff1f9 43.2MB
hub.c.163.com/library/nginx latest e5bc191dff1f9 43.2MB
nerdctl rmi 镜像 删除镜像
nerdctl rmi 192.168.26.100/cka/nginx #没指明标签默认就是lastest
nerdctl rmi 192.168.26.100/cka/nginx:v2
nerdctl save 镜像名 > filename.tar #将镜像保存为本地文件
#导出镜像nerdctl save nginx > nginx.tar 然后删除nginx镜像 nerdctl rmi nginx
#导入镜像 nerdctl load -i nginx.tar
[root@vms71 yum.repos.d]# nerdctl save 192.168.26.71/nginx:v1 > nginx.tar
[root@vms71 yum.repos.d]# nerdctl rmi 192.168.26.71/nginx:v1
Untagged: 192.168.26.71/nginx:v1@sha256:8eeb06742b41fb67514e4b14049f6740dc582520486d7a1612e78c55b1dbe40e
Deleted: sha256:f85d5ff897c4b43e5c17c8014d2ba402ce97487b538d033e3b57c535bde9cc73
Deleted: sha256:a4fc47c1db155e3f7cc36f1da913f889fd1e7b7af8ce975861891a6a8fdb43ed
Deleted: sha256:48be3b91dcb800cb6e44bdd99081895b2b375b507ff1865da66e2e74da92bd43
[root@vms71 yum.repos.d]# nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
[root@vms71 yum.repos.d]# nerdctl load -i nginx.tar
unpacking 192.168.26.71/nginx:v1 (sha256:8eeb06742b41fb67514e4b14049f6740dc582520486d7a1612e78c55b1dbe40e)...
Loaded image: 192.168.26.71/nginx:v1[root@vms71 yum.repos.d]# nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
192.168.26.71/nginx v1 8eeb06742b41 3 seconds ago linux/amd64 113.3 MiB 41.2 MiB
显示images信息
[root@vms71 yum.repos.d]# nerdctl history 192.168.26.71/nginx:v1 --no-trunc
SNAPSHOT CREATED CREATED BY SIZE COMMENT
<missing> 5 years ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon off;"] 0.0 B
<missing> 5 years ago /bin/sh -c #(nop) STOPSIGNAL [SIGQUIT] 0.0 B
<missing> 5 years ago /bin/sh -c #(nop) EXPOSE 80/tcp 0.0 B
sha256:c0b12ee2963d151e3e5ff6e7cbd5877101adc6394c9bb5a2764905e407454d08 5 years ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log 0.0 B
sha256:86f1e4ccbe2c924248881bfbb94dd774bbdf49232e8b1ca77b1a2788bd2e045c 5 years ago /bin/sh -c apt-get update && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 && NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; found=''; for server in ha.pool.sks-keyservers.net hkp://keyserver.ubuntu.com:80 hkp://p80.pool.sks-keyservers.net:80 pgp.mit.edu ; do echo "Fetching GPG key $NGINX_GPGKEY from $server"; apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; done; test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* && echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y nginx=${NGINX_VERSION} nginx-module-xslt=${NGINX_VERSION} nginx-module-geoip=${NGINX_VERSION} nginx-module-image-filter=${NGINX_VERSION} nginx-module-njs=${NJS_VERSION} gettext-base && rm -rf /var/lib/apt/lists/* 51.3 MiB
<missing> 5 years ago /bin/sh -c #(nop) ENV NJS_VERSION=1.13.0.0.1.10-1~stretch 0.0 B
<missing> 5 years ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.13.0-1~stretch 0.0 B
<missing> 5 years ago /bin/sh -c #(nop) MAINTAINER NGINX Docker Maintainers "[email protected]" 0.0 B
<missing> 5 years ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0.0 B
sha256:f85d5ff897c4b43e5c17c8014d2ba402ce97487b538d033e3b57c535bde9cc73 5 years ago /bin/sh -c #(nop) ADD file:253a2a9f49900b34f61c3c1527adb199bfc8ff153084604addb38a6769aadce7 in / 62.0 MiB
下一篇:nerdctl管理容器