oci distribution spec 比较简单,就是定义了一些用于pull/push 的api
一个有趣的事实是,oci registry 不只是存储镜像,也可以用于存储helm chart。
Pull
Pull manifest
- GET /v2//manifests/
- name: 一般是${namespace/image_name}, 比如 library/nginx
- reference:一般是digest或者tag,比如latest、v1.2.3、sha256:abc123…
- 拉取下来的是符合oci image spec的manifest文件
Pull blobs
- GET /v2//blobs/
Push
值得注意的是,在push image时,是先push blobs,再push manifest,与pull相反
Push blobs
- 单次Post
- 直接往 /v2//blobs/uploads/?digest= 进行Post,body就是blob二进制内容
- 先Post再Put
- Post /v2//blobs/uploads/ 拿到 upload url(upload url将被放在rsp header里的Location字段)
- 这里的location url往往是专用存储的地址,比如s3
- 随后上传二进制到 ?digest=
- Post /v2//blobs/uploads/ 拿到 upload url(upload url将被放在rsp header里的Location字段)
- 分块上传
- 不再赘述,和http chunk机制有关
- digest:
- 值得注意的是:
- A config file references the uncompressed layer contents by sha256.
- A manifest references the compressed layer contents by sha256 and the size of the layer.
- A manifest references the config file contents by sha256 and the size of the file.
- 这有一张图,很清晰 https://github.com/google/go-containerregistry/tree/d7f8d06c87ed209507dd5f2d723267fe35b38a9f/pkg/v1/remote#anatomy-of-an-image-upload
- 所以,从registry直接拉下来的manifest里的内容,会和docker save导出的manifest的内容会有差异,体现在blobs/layer的tar包是否有gzip过
- 值得注意的是:
Push manifest
- PUT /v2//manifests/