系统学习 DevOps 学习路径:从版本控制到可观测与供应链

crane

容器镜像搬运与检查工具

补充说明

crane 是 go-containerregistry 提供的命令行工具,直接操作 registry 中的镜像、manifest 和 layer,不需要 Docker daemon。适合 CI 中的复制、打标签和检查。

常用示例

crane auth login registry.example.com -u user -p "$PASSWORD"
crane ls registry.example.com/app
crane digest registry.example.com/app:1.0
crane manifest registry.example.com/app:1.0
crane config registry.example.com/app:1.0
crane pull registry.example.com/app:1.0 app.tar
crane push app.tar registry.example.com/app:1.0
crane copy registry.example.com/app:1.0 registry.example.com/app:stable
crane tag registry.example.com/app:1.0 stable
crane delete registry.example.com/app:old
crane validate --remote registry.example.com/app:1.0

易错点与排错

相关命令

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. 生产部署为什么优先固定 digest 而不是 tag?
  2. 多平台镜像的 manifest 与子平台清单有什么区别?
  3. crane 能构建镜像吗?它的职责是什么?
答案
  1. tag 可变而 digest 不可变,固定 digest 能保证部署的镜像内容不被替换。
  2. 多平台镜像的 manifest 是 manifest list,直接取 manifest 与取某个子平台清单得到的内容不同。
  3. 不能。crane 不构建镜像,只负责搬运和检查已有制品。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令