OCI vs CRI
TL;DR
- OCI: Open Container Initiative (https://www.opencontainers.org/)
- low-level specs: standarizes container images, runtimes, and registries.
- NOT specific to kubernetes.
- CRI: Container Runtime Interface
- high-level specs: enables
kubeletto talk to any OCI compliant container runtimes. - specific to Kubernetes.
- high-level specs: enables
The relationship can be illustrated as in this diagram:
Registry kubelet
| |
| v
(OCI distribution-spec) (CRI)
| |
| v
Containerfile -> Images -> Container Runtime -> Containers
Dockerfile (OCI image-spec) (OCI runtime-spec)
OCI: Open Container Initiative
OCI defines 3 important specs:
- the Runtime Specification(runtime-spec): standardizes container runtimes.
- the Image Specification(image-spec): what does an image look like.
- the Distribution Specification(distribution-spec): how images can be pulled.
OCI Image (image-spec)
Benefits:
- Deduplication of layers of images in releases; saving space.
- File verification thru SHA digests stored in Index and Manifests against file corruption.
- Listing Image Manifest of the bundle (before storing); full transparency to the customer.
Structure:
- OCI Image can be nested.
- A
oci-layoutfile specifying the layout version:"imageLayoutVersion": "1.0.0" - Root level must have:
index.jsonMediaTypeis either one of:- index:
application/vnd.oci.image.index.v1+json - manifest:
application/vnd.oci.image.manifest.v1+json
- index:
- Artifacts are stored in
oci/blobs/<alg>/<digest>, e.g.oci/blobs/sha256/XXXXXXXXXXXMediaType is flexible(Some are JSON some are binary)application/vnd.oci.image.config.v1+jsonapplication/vnd.oci.image.layer.v1.tar+gzip
- References are all done by digest
- "file whose digest is
sha256:cdce9e..." - instead of "file whose name is
layer.tar.gz"
- "file whose digest is
- Merkle DAG (Directed Acyclic Graph)
- content dedup by digest
- immutable - tamper proof
- no circular dependency
Docker images will use application/vnd.docker.* instead of application/vnd.oci.* in mediaType.
OCI Runtime Bundle (runtime-spec)
runc doesn't recognize images; runc is runtime-spec compliant, so it expects an OCI Runtime Bundle, which is basically a root filesystem and a config.json file.
OCI Image => (OCI converter / OCI Runtime Bundle Generator) => OCI Runtime Bundle => (runc) => container
OCI Runtime Bundle = a root filesystem + config.json
bundle/
|- config.json
|- rootfs/
The process:
- Start with an OCI Image.
- Apply the filesystem layers in the order specified in manifest.
- Generate
config.json. - OCI Runtime Spec bundle is formed,
runcnow has enough information to run. - apply cgroup / namespace etc on Linux host.
OCI Registries (distribution-spec)
Docker Registry v2 API is a well known specification for any Docker registry (docker.io, gcr.io, Harbor etc.). Any time you’re doing docker pull (or other Docker commands), the Docker client is interacting with the Docker registry using a protocol defined in Docker Registry v2 API specification.
OCI Distribution Specification is an effort to standardize the Docker Registry v2 API, which is largely the same as Docker Registry v2 API (intentional). Most of the Docker registry on the market nowadays supports it in addition to the Docker Registry v2 API support.
distribution-spec allows other "artifacts" (e.g. Helm charts) to be stored in OCI registries.
You can store charts, images, and other artifacts in a single OCI registry.
CRI: Container Runtime Interface
Defines an API between Kubernetes (kubelet) and the container runtime (defined by OCI).
- defines the main gRPC protocol for the communication between the cluster components
kubeletand container runtime. - CRI =
RuntimeService+ImageService: https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1/api.proto - The
kubeletacts as a client when connecting to the container runtime via gRPC. The runtime and image service endpoints have to be available in the container runtime.
- 32-bit vs 64-bit
- AES vs RSA
- Agent vs Agentless
- Annotations vs Decorators
- Terraform vs Ansible
- BASH vs ZSH
- BigQuery vs Bigtable
- Block Storage vs File Storage vs Object Storage
- Canvas vs SVG
- cgroupfs vs systemd
- Constructor vs Init() vs Factory
- Container Image vs Helm Chart vs OCI Bundle
- Containers vs Virtual Machines (VMs)
- C vs C++
- Java vs C++
- Rust vs C++
- crictl vs ctr
- Dagger vs Guice
- DMA vs RDMA
- DOM vs Virtual DOM vs Shadow DOM
- DQL vs DDL vs DCL vs DML
- eBPF vs Sidecar
- Flux vs Redux
- Full Disk Encryption vs Partition Encryption
- Gatekeeper vs OPA
- Google vs Open Source
- Why MCP uses JSON-RPC 2.0 instead of grpc
- gRPC vs OpenAPI
- gtag.js vs Google Tag Manager (GTM)
- Versus
- Kotlin vs Java
- Jetty vs Netty
- .js vs .jsx vs .ts vs .tsx
- Kata Containers vs KubeVirt
- Linux Namespace vs Kubernetes Namespace
- Linux vs BSD
- LLVM vs JVM
- Data Mining vs Machine Learning vs Artificial Intelligence vs Data Science
- Managed Kubernetes vs Self-managed Kubernetes
- Management Plane vs Control Plane vs Data Plane
- Microcontroller vs Microprocessor vs Computer
- MMU vs IOMMU
- Single-tenant vs Multi-tenant vs Multi-single-tenant
- Multithreading vs Multiprocessing vs Distributed Systems
- Node.js vs Erlang
- OCI Image vs Docker Image
- OCI vs CRI
- OpenSSH vs OpenSSL
- Pass-by-value vs Pass-by-reference
- Podman vs nerdctl
- POSIX vs SUS vs LSB
- Private Key vs Public Key vs Certificate
- Proto Edition 2024 vs Proto Edition 2023
- Proto2 vs Proto3 vs Proto Editions
- Message Queue vs PubSub
- React vs Flutter vs Angular
- REST vs SOAP
- RSA vs ECDSA
- select vs. poll vs. epoll
- SLI vs SLO vs SLA
- Spanner vs Bigtable
- Static Site Generation vs Server-side Rendering vs Client-side Rendering
- Stack based VM vs Register based VM
- Stateless vs Stateful
- Strong Consistency vs Eventual Consistency
- stubs vs mocks vs fakes
- Subroutines vs Coroutines vs Generators
- Software Engineer vs Site Reliability Engineer
- Symlinks vs Hard Links
- JAX vs Tensorflow
- Tensorflow vs PyTorch
- Terminal vs Shell
- Throttling vs Load Shedding
- Unix Domain Sockets vs Network Sockets
- Unix Domain Sockets vs Shared Memory
- URI vs URN vs URL vs URC
- Valkey vs Redis vs Memcached
- Vi vs Vim vs gVim vs Neovim
- WAL vs rollback journal

