containerd 使用 ctr 命令,即:containerd CLI
1. ctr images help
root@suaxi:~# ctr images -h
NAME:
ctr images - Manage images
USAGE:
ctr images command [command options] [arguments...]
COMMANDS:
check Check existing images to ensure all content is available locally
export Export images
import Import images
list, ls List images known to containerd
mount Mount an image to a target path
unmount Unmount the image from the target
pull Pull an image from a remote
push Push an image to a remote
prune Remove unused images
delete, del, remove, rm Remove one or more images by reference
tag Tag an image
label Set and clear labels for an image
convert Convert an image
usage Display usage of snapshots for a given image ref
OPTIONS:
--help, -h show help
2. 查看镜像
ctr images ls
3. 拉取镜像
containerd 支持 oci 标准的镜像,所以可以直接使用 docker 官方或 dockerfile 构建的镜像。
# 拉取时镜像名需要写全量名称(源 + 镜像名:TAG)
ctr images pull --all-platforms docker.io/library/nginx:alpine
# 拉取指定平台的镜像(x86)
ctr images pull --platform linux/amd64 docker.io/library/nginx:alpine
4. 删除镜像
ctr image rm docker.io/library/nginx:alpine
5. 导出镜像
ctr i export --all-platforms nginx.img docker.io/library/nginx:alpine
6. 导入镜像
# 以上一步导出的 nginx.img 镜像为例
ctr images import nginx.img unpacking docker.io/library/nginx:alpine
7. 修改镜像 tag
# 将 docker.io/library/nginx:alpine 修改为 nginx:alpine-test
ctr images tag docker.io/library/nginx:alpine nginx:alpine-test
修改后检查镜像
ctr images check
评论 (0)