DockerStoring and Distributing Multi-GB Container Images
Design a container image distribution service. Users push images that are hundreds of MB to several GB, pull them by tag or digest, list available images, and search.
Problem
Design a container image distribution service. Users push images (hundreds of MB to several GB each), pull them by tag or by digest, list the images and tags that exist, and search for images.
Cover the API surface, the data model, the push and pull flows, how concurrent pushes to the same tag behave, how unused data is reclaimed, and a capacity estimate. A reasonable planning load is about 5M pulls per day.
In the senior SWE onsite it can also be framed as "design a Docker image service, like Dropbox": file-style storage and distribution, but for images. Clarify the scope (push, pull, list, search) before you start the design.
Hints
Pitfalls
- A layer still referenced by another image cannot be deleted; only manifests are deleted, and a layer goes only when no manifest references it (reference counting or reachability sweep).
- Moving a tag does not delete the old manifest; it stays pullable by digest until GC.
- Without dedup, 100M images at about 1 GB is roughly 100 PB; a typical 10x layer dedup brings it near 10 PB.
Talking Points
- Content-addressed layers are the foundation: dedup, CDN caching, HEAD checks and incremental pulls all follow from it.
- Keep tag resolution and blob retrieval separate so they scale and cache independently.
- State the concurrent-push answer explicitly: atomic tag update, last writer wins, data committed before the flip.
- Walk through the HEAD-before-upload optimization; it shows you know how clients behave.
- Do the capacity math aloud (58 TPS average, about 250 peak).
- Treat GC as a correctness issue: use a grace period so sweeps do not race in-flight pulls.
- Tag-addressed manifests need short TTLs; layers cache forever.
- Mention rate limits and cost; it is the real business pressure on a public registry.
Follow-ups
Preparation
- Run a local
registry:2, inspect its on-disk layout. - Sketch the push and pull sequence from memory in 10 minutes, including HEAD check and tag flip.
- Write the five-table schema and say which index serves each query.
- Redo the capacity estimate (TPS, daily storage, dedup effect) in under 5 minutes.
