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.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install d71cfb41-398f-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
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).
常见问题
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.
引用来源 (3)
- Distribution GitHub— Reference implementation of OCI Distribution Specification
- OCI Distribution Spec— OCI Distribution Specification
- Docker Registry Documentation— Container registry best practices
讨论
相关资产
Skopeo — Registry-Agnostic Container Image Toolkit
Skopeo inspects, copies, signs, and deletes container images across registries without a daemon — the Swiss Army knife for OCI image plumbing in CI pipelines.
Harbor — Cloud Native Trusted Container Registry
Harbor is a CNCF-graduated open-source container registry that stores, signs, and scans container images. Vulnerability scanning, RBAC, replication, and OCI support.
runc — Industry-Standard OCI Container Runtime
The reference implementation of the OCI runtime specification, runc spawns and manages containers at the lowest level for Docker, containerd, Podman, and CRI-O.
Podman — Daemonless Container Engine for OCI Containers
Podman is a daemonless, open-source tool for developing, managing, and running OCI containers and pods. Drop-in replacement for Docker CLI without requiring a root daemon. Used by Red Hat, Fedora, and increasingly adopted in enterprise environments.