Open Container Initiative Image
Last updated
Last updated
oci image = manifest + image index (optional) + fs layers + configuration
application/vnd.oci.descriptor.v1+json: Content Descriptor
application/vnd.oci.layout.header.v1+json: OCI Layout
application/vnd.oci.image.index.v1+json: Image Index
application/vnd.oci.image.manifest.v1+json: Image manifest
application/vnd.oci.image.config.v1+json: Image config
application/vnd.oci.image.layer.v1.tar: "Layer", as a tar archive
application/vnd.oci.image.layer.v1.tar+gzip: "Layer", as a tar archive compressed with gzip
application/vnd.oci.image.layer.v1.tar+zstd: "Layer", as a tar archive compressed with zstd
application/vnd.oci.image.layer.nondistributable.v1.tar: "Layer", as a tar archive with distribution restrictions
application/vnd.oci.image.layer.nondistributable.v1.tar+gzip: "Layer", as a tar archive with distribution restrictions compressed with gzip
application/vnd.oci.image.layer.nondistributable.v1.tar+zstd: "Layer", as a tar archive with distribution restrictions compressed with zstd
image index는 여러개의 image manifest를 가질 수 있음
image manifest는 하나의 config와 여러 layer를 가질 수 있음
manifest를 통해 달성하려 하는 목표는 크게 봐서 3가지이다. 하나는 content-addressable image를 만드는 것이다. 이는 image의 configuration을 해싱했을 때 그 image 자신과 구성 요소들을 unique하게 식별할 수 있게 만들면 된다. 두번째 목표는 multi-architecture image를 가능케 하는 것이다. 이것은 image index로 가능해진다. image index는 일종의 "fat manifest" 이고 여러 특정 플랫폼용 image를 한번에 관리하는 것이 가능하게 만든다. 마지막 목표는 OCI Runtime Specification으로 변환이 가능케 하는 것이다.
image manifest는 image configuration과 fs layers에 대한 정보들을 가지고 있다. 이 때 이 정보는 특정 architecture, os에 국한된 것이다.
application/vnd.oci.image.manifest.v1+json
image index는 상위 레벨의 manifest라고 생각하면 된다. 여러 개의 manifest를 가지고 있고 그 각각의 manifest가 어떤 플랫폼에 가장 적합한지 가르키는 정보를 포함하고 있다.
application/vnd.oci.image.index.v1+json
정확히는 "Image Layer Filesystem Changeset" 말 그대로 파일 시스템 변경 내역이 바로 이미지의 레이어이다. 이 레이어들이 차곡차곡 쌓여서 하나의 완전한 파일시스템을 이룬다.
application/vnd.oci.image.layer.v1.tar
application/vnd.oci.image.layer.v1.tar+gzip
application/vnd.oci.image.layer.v1.tar+zstd
application/vnd.oci.image.layer.nondistributable.v1.tar
application/vnd.oci.image.layer.nondistributable.v1.tar+gzip
application/vnd.oci.image.layer.nondistributable.v1.tar+zstd
layer의 payload가 gzip으로 압축됨
레이어는 반드시 tar로 묶어야하고 완성된 tar archive에는 중복되는 엔트리가 존재하지 않아야 함.
Additions
Modifications
Removals
이 중 Additions와 Modifications는 tar archive 시점에서는 동일하게 취급되고 Removals만 whiteout file entries로 적용된다.
regular files
directories
sockets
symbolic links
block devices
character devices
FIFOs
Modification Time (mtime
)
User ID (uid
)
User Name (uname
) secondary to uid
Group ID (gid
)
Group Name (gname
) secondary to gid
Mode (mode
)
Extended Attributes (xattrs
)
Symlink reference (linkname
+ symbolic link type)
layer를 생성하는 과정은 다음과 같다.
root 파일 시스템 초기화: root 파일 시스템은 base 또는 이전 레이어
비교를 위한 파일시스템 생성: 단순히 파일 시스템을 복사하거나 이전 root 파일 시스템의 snapshot 생성
변경내역 결정: 파일시스템에 추가, 변경, 삭제된 것들을 비교
변경된 것들만 모아서 새로운 tar archive 생성: Added, Modified는 변경된 파일을 엔트리에 등록. Deleted는 whiteout 파일을 엔트리에 등록
whiteout 파일을 처리하는 것을 제외하고는 일반적인 tar archive extract랑 동일하게 동작.
tar 엔트리를 처리하는 과정에서 이미 존재하는 파일이 있을 때 그 파일이 directory이면 file attributes만 엔트리 기준으로 적용하고 나머지 타입의 파일들은 삭제하고 엔트리 파일로 새로 생성해넣는다.
whiteout 파일은 이름이 .wh.
으로 시작하는 빈 파일로 부모 레이어에서 이 이름을 가진 파일이 삭제되었음을 표시. whiteout 파일의 순서에 상관없이 가장 먼저 처리되어야 한.
.wh..wh..opq
이름을 가진 특별한 whiteout 파일로 이 파일이 존재하는 path의 모든 child 가 삭제되었음을 표시한. 만약에 이 파일과 같은 path에 entry가 존재한다면 삭제된 다음 다시 생성되었다는 의미이.
법이나 기타등등 여러가지 사정으로 인하여 일반적으로 사용하는 것 처럼 배포할 수 없는 레이어들이다. 예를 들면 마이크로소프트의 윈도우 베이스 이미지 같은게 있다. 이러한 "non-distributable" 레이어들은 인증받은 특정 url에서 직접 다운로드 받아야하고 레지스트리에 업로드되면 안된다. 따라서 non-distributable 레이어의 Descriptor에는 보통 이러한 레이어를 직접적으로 받을 수 있는 url이 urls
필드에 기록되어있는 경우가 많다.
layer의 payload가 으로 압축
reference (linkname
)