Distribution — The OCI Container Registry Toolkit
The reference implementation of the OCI Distribution Specification for storing and distributing container images and artifacts. Distribution powers Docker Hub, GitHub Container Registry, and most private registries behind the scenes.
What it is
Distribution is the reference implementation of the OCI Distribution Specification. It provides a container image registry that stores and serves Docker and OCI container images. This is the same codebase that powers Docker Hub, GitHub Container Registry (GHCR), and most private registries. You deploy it as a single binary or Docker container to host your own image registry.
Distribution targets platform engineers, DevOps teams, and organizations that need a private container registry for security, compliance, or performance reasons.
How it saves time or tokens
Pulling images from public registries like Docker Hub introduces rate limits, latency, and dependency on external infrastructure. Running your own registry with Distribution eliminates rate limits, keeps images on your network, and gives you full control over access. For CI/CD pipelines that build and deploy frequently, a local registry cuts image pull times from seconds to milliseconds.
How to use
- Run a local registry:
docker run -d -p 5000:5000 --name registry registry:2
- Tag and push an image:
docker tag my-image localhost:5000/my-image
docker push localhost:5000/my-image
- Pull from your registry:
docker pull localhost:5000/my-image
Example
# docker-compose.yml - Production registry with persistent storage
version: '3'
services:
registry:
image: registry:2
ports:
- '5000:5000'
volumes:
- registry-data:/var/lib/registry
environment:
REGISTRY_STORAGE_DELETE_ENABLED: 'true'
REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '["*"]'
volumes:
registry-data:
This sets up a persistent registry with image deletion enabled.
Related on TokRepo
- DevOps Tools -- Container and infrastructure automation tools
- Self-Hosted Solutions -- Self-hosted infrastructure platforms
Common pitfalls
- The default registry has no authentication. Add TLS and basic auth or token auth before exposing it outside localhost.
- Storage grows indefinitely without garbage collection. Run
registry garbage-collectperiodically to reclaim space from deleted images. - Docker requires HTTPS for non-localhost registries by default. Either add TLS certificates or configure Docker to allow insecure registries (not recommended for production).
Frequently Asked Questions
Yes. Docker Registry v2 is built on the Distribution project. The registry:2 Docker image is the official Distribution release. The project moved from Docker to the CNCF under the name Distribution.
Yes. Distribution implements the OCI Distribution Specification and supports storing any OCI artifact, including Helm charts, Wasm modules, and supply chain artifacts like SBOMs.
Distribution supports htpasswd-based basic auth, token-based auth, and external auth services. Configure the auth section in the registry config.yml file. For production, use token-based auth with TLS.
Distribution itself does not include built-in replication. Use tools like Skopeo, crane, or Harbor (which uses Distribution under the hood) for cross-registry image replication.
Storage depends on image count and size. Container images range from tens of MB to several GB. Plan for at least 100GB for a moderate team. Enable garbage collection and set retention policies to manage growth.
Citations (3)
- Distribution GitHub— Reference implementation of OCI Distribution Specification
- OCI Distribution Spec— OCI Distribution Specification
- Docker Registry Documentation— Container registry best practices
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.