Open Container Initiative(OCI)は、の一種である「コンテナ」のフォーマット・ランタイムの業界標準策定を目的として設立されたイニシアチブであるfor the express purpose of creating open industry standards around container formats and runtime. 。Linux Foundationプロジェクトの1つであるformed under the auspices of the Linux Foundation 。

概要 OSレベル仮想化手法の1つとして、Dockerをはじめとするコンテナ仮想化技術がある。複数存在するコンテナ仮想化実装のオープン業界標準策定を目的として設立されたのがOpen Container Initiativeである。

OCIが策定した標準仕様は以下の2つであるThe OCI currently contains two specifications: the Runtime Specification (runtime-spec) and the Image Specification (image-spec). 。

Open Container Initiative Runtime Specification OCI Image Format Specification

またOCIは上記仕様のリファレンス実装であるrunCを開発しており、これは高レベルのツールを開発する際のベースとなっている。

OCI Runtime Spec Container OCI RuntimeにおけるContainerは「『隔離とリソース制限を設定可能なプロセス実行』を提供する1つの環境」であるAn environment for executing processes with configurable isolation and resource limitations. OCI Runtime Spec。例えばruncランタイム上で生成されたContainerは他のコンテナからファイルシステムやプロセスが隔離され、利用可能なCPUリソース等に制限がかけられている。ゆえにこのコンテナ(環境)内で実行されるプロセスは隔離とリソース制限を得ることができる。

OCI Runtime SpecではこのContainerのライフサイクル等を定義している。

status OCI Containerはcreating, created, running, stopped以下のいずれかの状態あるいはランタイムが拡張した状態にあるThe state of a container includes the following properties... (中略) ...status (string, REQUIRED) is the runtime state of the container. The value MAY be one of: OCI Runtime Spec。

Runtime OCIにおけるRuntimeはContainerの管理を司るプログラムである。Runtimeはbundleから設定ファイルを読み込み、それに基づいてコンテナを生成、コンテナ内でプロセスを起動し、その他のコンテナライフサイクル管理を実行するIt reads the configuration files from a bundle, uses that information to create a container, launches a process inside the container, and performs other lifecycle actions. OCI Runtime Spec。

OCI Runtime Specに準拠した様々なコンテナランタイムが実装されている。

runc: 広く利用されているリファレンス実装。containerdcontainerd is built with OCI support and with support for advanced features provided by runc. (を利用するDockerBy default, the Docker daemon automatically starts containerd)やcri-oCRI-O then launches an OCI Compatible Runtime using the specification to run the container proceses. The default OCI Runtime is runc. のランタイムとして利用されている kata-runtime: 軽量VMで高い安全性を志向するKata ContainersKata Containers is an open source community working to build a secure container runtime with lightweight virtual machines のランタイムkata-runtime, referred to as "the runtime" ...(ry)... The runtime is OCI-compatible, CRI-O-compatible, and Containerd-compatible, allowing it to work seamlessly with both Docker and Kubernetes respectively. runsc: 高い安全性を志向するgVisorのランタイムIt includes an Open Container Initiative (OCI) runtime called runsc that provides an isolation boundary between the application and the host kernel.

他にも様々なランタイムが開発された。

RailCar: Rustで実装されたOCI Runtime実装 (開発終了)

filesystem bundle OCIにおける filesystem bundle は、コンテナに必要な全ファイルが定められた形式で配置された1つのセットであるa filesystem bundle - a set of files organized in a certain way, and containing all the necessary data and metadata for any compliant runtime to perform all standard operations against it. OCI Runtime Spec。bundleは設定情報を含むconfig.jsonおよびコンテナのrootファイルシステムから成る。Runtimeはコンテナidとfilesystem bundleからコンテナを生成するOCI compliant runtime's create command is invoked with a reference to the location of the bundle and a unique identifier. OCI Runtime Spec。

OCI Image OCI ImageはOCI Image Format Specificationによって定義されるコンテナイメージ仕様であるThis specification defines an OCI Image 。OCI Imageにはディレクトリ/ファイル情報と実行時設定が含まれておりAn OCI Image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. 、OCI Imageに準拠したコンテナイメージをOCI Runtimeに準拠したコンテナランタイムへ渡すことでコンテナを実行できるan OCI implementation would download an OCI Image then unpack that image into an OCI Runtime filesystem bundle. At this point the OCI Runtime Bundle would be run by an OCI Runtime. 。

OCI Imageは以下の4要素で構成されるconsisting of a manifest, an image index (optional), a set of filesystem layers, and a configuration. 。

Manifest: コンテナイメージに含まれるlayersとconfigurationのハッシュ値等が記述されたJSONファイルan image manifest provides a configuration and set of layers for a single container image for a specific architecture and operating system. (例) image index (任意) set of filesystem layers: ファイルシステムのchangesets (tar, tar.gz, tar.zstdとメタデータ) Configuration: アプリケーションの引数、環境変数等の設定情報が記述されたJSONファイルThe image configuration includes information such as application arguments, environments, etc. (例)

OCI Imageはファイルシステム情報をそのまま持つのではなく、changesetつまり元ファイルシステムに対する変更差分を用いて保有している(c.f. Git)。これにより元ファイルシステムにすべての変更履歴(layers)を適用することで完全なファイルシステムを生成できるようになっている。

OCI Runtimeでは、OCI Image layersから得られたファイルシステム実体とImage Configurationの変換で得られたconfig.jsonからfilesystem bundleを得ることでコンテナを生成する(image → bundle → container)。

脚注

外部リンク