Overview
9 Public and private software distribution
This chapter explains how Docker images are shared and installed by others, presenting distribution as a spectrum from fully hosted services to custom-built pipelines and source sharing. Because no single method fits every use case, it introduces a set of practical selection criteria—cost, visibility, transport performance, longevity and availability control, access control, artifact integrity and confidentiality, and requisite expertise—to help you make informed trade-offs. A key theme is that all options build on Docker’s core tooling, so teams can migrate between methods as requirements change.
On the simplest end, hosted registries (public and private) make publishing straightforward. Public repositories are typically free, highly visible, and efficient thanks to layer-aware transfers, but you give up availability control and must never treat them as a place for secrets. Private hosted repositories add access controls and suit small teams, yet still leave availability and longevity in a provider’s hands. Running your own private registry shifts control to you—supporting regional caches, team- or environment-specific pools, and stricter secrecy—while preserving familiar push/pull workflows and integrity features. The trade-off is operational responsibility for storage, security (TLS, auth, encryption at rest), scale, and uptime.
Moving further along the spectrum, manual distribution treats images as files moved through any channel (from cloud storage to USB), maximizing flexibility for air-gapped or unusual environments but sacrificing registry benefits like layer deduplication, parallelism, and built-in integrity; security and integrity depend on your added processes (signing, checksums, encryption). The most flexible approach is distributing sources (for example, Dockerfiles via version control) and letting consumers build locally, which can reduce transport size by leveraging existing base images and improve discoverability for public projects, while offering no availability control and placing more build and tooling burden on producers and consumers. Selecting a method ultimately means applying the chapter’s criteria to your constraints and choosing the balance of simplicity, performance, security, and control you need.
Summary
This chapter covers various software distribution mechanisms and the value contributed by Docker in each. A reader that has recently implemented a distribution channel, or is currently doing so, might take away additional insights into their solution. Others will learn more about available choices. In either case, it is important to make sure that you have gained the following insights before moving on:
- Having a spectrum of choices illustrates your range of options.
- You should use a consistent set of selection criteria in order to evaluate your distribution options and determine which method you should use.
- Hosted public repositories provide excellent project visibility, are free, and require very little experience to adopt.
- Consumers will have a higher degree of trust in images generated by automated builds because a trusted third party builds them.
- Hosted private repositories are cost-effective for small teams and provide satisfactory access control.
- Running your own registry enables you to build infrastructure suitable for special use cases without abandoning the Docker distribution facilities.
- Distributing images as files can be accomplished with any file-sharing system.
- Image source distribution is flexible but only as complicated as you make it. Using popular source-distribution tools and patterns will keep things simple.
FAQ
What distribution options for Docker images does this chapter cover?
The chapter presents a spectrum of distribution methods, from the simplest to the most flexible: hosted registries (public and private), self-hosted private registries, manual image distribution using generic file transports, and distributing image sources instead of images. Each option balances ease of use, control, security, and performance differently. The “right” choice depends on your project’s requirements and constraints.
How should I choose a Docker image distribution method?
Use a consistent set of criteria: cost, visibility, transport speed/bandwidth, longevity control, availability control, access control, artifact integrity, confidentiality, and requisite expertise. Rank how important each criterion is for your situation, then compare methods against them. There’s no universal best method; Docker’s tooling makes it feasible to switch as your needs evolve.
When are hosted registries (like Docker Hub, Quay, GCR) a good fit?
Hosted registries are ideal for quick starts, open-source distribution, and teams that don’t want to run infrastructure. They’re layer-aware, efficient to pull from, and widely discoverable (for public repos). They offer strong integrity via the V2 API and content-addressable images, but you have no availability or longevity control and they’re not appropriate for storing cleartext secrets.
How do I publish an image to a public repository on Docker Hub?
Build your image and tag it as username/repo, authenticate with docker login, and push with docker image push. The registry will create the repo, upload missing layers, and register tags; clients can discover it via search or the web UI. Keep the repository under your account or organization to retain write access. Avoid embedding secrets in images you publish publicly.
What are the trade-offs of private hosted repositories compared to public ones?
Private hosted repos add access control for both reads and writes and keep projects out of public indexes, while retaining the convenience and performance of hosted registries. Costs scale with repo counts, and you still lack direct availability and longevity control (though SLAs/support may improve your position). Despite being private, they’re still not suitable for storing cleartext secrets or highly sensitive code.
When should I run my own private registry, and what does it involve?
Run a private registry when you require tight control over availability, longevity, network placement, or secrecy, or need specialized workflows (regional caches, stage-specific pools, corporate approval gates). Using the open-source Distribution (registry:2) keeps engineering cost low and preserves Docker push/pull interoperability. Production use typically entails TLS, authentication/authorization, durable storage, caching/proxying, and operational expertise.
How do I use a local/private registry to mirror or host images?
Start a registry (for example, registry:2), tag images with your registry’s hostname (such as localhost:5000/namespace/name), and push them. Consumers pull from your registry just like any hosted registry. The default local demo config is insecure; for real use you’ll add TLS and auth, and configure storage backends and proxies as needed.
What is manual image distribution, and when would I consider it?
Manual distribution treats images as files that you save, transport, and load using generic channels (HTTP/HTTPS, SFTP, rsync, USB, etc.). It offers maximum flexibility, including air-gapped and one-off event scenarios, but puts responsibility for visibility, versioning, integrity, access control, and encryption on you. It’s best for special environments or requirements that registries don’t serve well.
What does the FTP-based example illustrate, and why isn’t FTP recommended?
The example shows how to export an image to a tar file, upload it to an FTP server, and let clients download and load it. It highlights gaps you must solve yourself: advertising availability, versioning, access control, integrity, and secrecy. Plain FTP lacks encryption and integrity guarantees; prefer secure transports (SFTP/SSH, HTTPS) and add checksums or signatures if you pursue a similar workflow.
How does distributing image sources (e.g., via GitHub) compare to distributing images?
Source distribution shifts delivery to tools like Git and relies on docker image build at the consumer side. It offers excellent visibility (for public repos), leverages CDNs, and can reduce transport by reusing base images from registries. You lose availability/longevity control when using hosted VCS, need users comfortable with Git and Dockerfiles, and must handle any confidentiality needs with private repos and appropriate access controls.