ScriptsApr 16, 2026·3 min read

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.

TL;DR
Distribution is the reference OCI container registry implementation that powers Docker Hub, GitHub Container Registry, and most private registries.
§01

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.

§02

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.

§03

How to use

  1. Run a local registry:
docker run -d -p 5000:5000 --name registry registry:2
  1. Tag and push an image:
docker tag my-image localhost:5000/my-image
docker push localhost:5000/my-image
  1. Pull from your registry:
docker pull localhost:5000/my-image
§04

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.

§05

Related on TokRepo

§06

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-collect periodically 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

Is Distribution the same as Docker Registry?+

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.

Does Distribution support OCI artifacts?+

Yes. Distribution implements the OCI Distribution Specification and supports storing any OCI artifact, including Helm charts, Wasm modules, and supply chain artifacts like SBOMs.

How do I add authentication?+

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.

Can Distribution replicate images between registries?+

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.

How much storage does a registry need?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets